Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix custom config parameter bugs #81

Merged
merged 1 commit into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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