Skip to content

Commit

Permalink
fix custom config parameter bugs (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaByte875 authored Oct 28, 2021
1 parent 63f7cc4 commit 10757cc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/util/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"bytes"
"fmt"
"regexp"
"sort"
"strings"
)

Expand Down Expand Up @@ -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()
Expand Down
29 changes: 29 additions & 0 deletions pkg/util/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
`,
},
}
Expand Down

0 comments on commit 10757cc

Please sign in to comment.