mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Merge pull request #673 from yamt/sort-args
Sort args to make log outputs a bit more deterministic
This commit is contained in:
commit
c86e95062a
@ -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
|
||||
}
|
||||
|
39
pkg/daemons/config/types_test.go
Normal file
39
pkg/daemons/config/types_test.go
Normal file
@ -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…
Reference in New Issue
Block a user