diff --git a/pkg/daemons/config/types.go b/pkg/daemons/config/types.go index c8bf48a721..bf552938a6 100644 --- a/pkg/daemons/config/types.go +++ b/pkg/daemons/config/types.go @@ -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 } diff --git a/pkg/daemons/config/types_test.go b/pkg/daemons/config/types_test.go new file mode 100644 index 0000000000..15780b090f --- /dev/null +++ b/pkg/daemons/config/types_test.go @@ -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) + } +}