diff --git a/pkg/util/config/config.go b/pkg/util/config/config.go index 3b832ac9..b15f33d5 100644 --- a/pkg/util/config/config.go +++ b/pkg/util/config/config.go @@ -21,6 +21,7 @@ import ( "bytes" "fmt" "regexp" + "sort" "strings" ) @@ -66,8 +67,14 @@ func AppendCustomConfig(data string, custom map[string]string) string { if len(custom) > 0 { _, _ = b.WriteString("\n########## Custom ##########\n") } - for k, v := range custom { - _, _ = b.WriteString(fmt.Sprintf("--%s=%s\n", k, v)) + + var sortedKeys []string + for k := range custom { + sortedKeys = append(sortedKeys, k) + } + sort.Strings(sortedKeys) + for _, k := range sortedKeys { + _, _ = b.WriteString(fmt.Sprintf("--%s=%s\n", k, custom[k])) } return b.String() diff --git a/pkg/util/config/config_test.go b/pkg/util/config/config_test.go index cf291b1b..82067f08 100644 --- a/pkg/util/config/config_test.go +++ b/pkg/util/config/config_test.go @@ -99,6 +99,35 @@ func TestAppendCustomConfig(t *testing.T) { ########## Custom ########## --enable_optimizer=true +`, + }, + { + name: "multi custom parameter not in template", + data: template, + custom: map[string]string{ + "enable_optimizer": "true", + "max_log_size": "100", + "logtostderr": "true", + "log_dir": "logs", + "symbolize_stacktrace": "false", + }, + want: ` +########## authorization ########## +# Enable authorization +--enable_authorize=false + +########## Authentication ########## +# User login authentication type, password for nebula authentication, ldap for ldap authentication, cloud for cloud authentication +--auth_type=password + +--rocksdb_compression_per_level= + +########## Custom ########## +--enable_optimizer=true +--log_dir=logs +--logtostderr=true +--max_log_size=100 +--symbolize_stacktrace=false `, }, }