Sort args to make log outputs a bit more deterministic

pull/673/head
YAMAMOTO Takashi 5 years ago
parent 1833b65fcd
commit 35d972fd72

@ -5,6 +5,7 @@ import (
"fmt"
"net"
"net/http"
"sort"
"strings"
"k8s.io/apiserver/pkg/authentication/authenticator"
@ -164,5 +165,6 @@ func GetArgsList(argsMap map[string]string, extraArgs []string) []string {
cmd := fmt.Sprintf("--%s=%s", arg, value)
args = append(args, cmd)
}
sort.Strings(args)
return args
}

@ -0,0 +1,39 @@
package config
import (
"reflect"
"testing"
)
func TestGetArgsList(t *testing.T) {
argsMap := map[string]string{
"aaa": "A",
"bbb": "B",
"ccc": "C",
"ddd": "d",
"eee": "e",
"fff": "f",
"ggg": "g",
"hhh": "h",
}
extraArgs := []string{
"bbb=BB",
"ddd=DD",
"iii=II",
}
expected := []string{
"--aaa=A",
"--bbb=BB",
"--ccc=C",
"--ddd=DD",
"--eee=e",
"--fff=f",
"--ggg=g",
"--hhh=h",
"--iii=II",
}
actual := GetArgsList(argsMap, extraArgs)
if !reflect.DeepEqual(actual, expected) {
t.Errorf("got %v\nwant %v", actual, expected)
}
}
Loading…
Cancel
Save