Skip to content

Commit

Permalink
Maintaining backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmayja committed Dec 18, 2024
1 parent f5d3a82 commit 8da3bde
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
4 changes: 3 additions & 1 deletion asconfig/conffilereader.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ func process(log logr.Logger, scanner *bufio.Scanner, conf Conf) (Conf, error) {
// Except end of section there should
// be atleast 2 tokens
if len(tok) < 2 {
if isSpecialOrNormalBoolField(tok[0]) {
// if enable benchmark presence is
// enable
if isSpecialBoolField(tok[0]) || isSpecialOrNormalBoolField(tok[0]) {
conf[tok[0]] = true
continue
}
Expand Down
8 changes: 4 additions & 4 deletions asconfig/conffilewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,16 @@ func writeListField(
}
}

func writeSpecialBoolField(buf *bytes.Buffer, key string, indent int) {
buf.WriteString(indentString(indent) + key + "\n")
}

func writeField(buf *bytes.Buffer, key, value string, indent int) {
switch {
case isFormField(key):
return
case isEmptyField(key, value):
return
case isSpecialBoolField(key):
if strings.EqualFold(value, "false") {
return
}
}

buf.WriteString(indentString(indent) + key + " " + value + "\n")
Expand Down
18 changes: 18 additions & 0 deletions asconfig/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,24 @@ func isSpecialOrNormalBoolField(key string) bool {
return key == "run-as-daemon"
}

// isSpecialBoolField returns true if the passed key
// in aerospike config is boolean type field but does not
// need true or false in config file. Their mere presence
// config file is true/false.
// e.g. namespace and storage level benchmark fields
func isSpecialBoolField(key string) bool {
switch key {
case "enable-benchmarks-batch-sub", "enable-benchmarks-read",
"enable-benchmarks-udf", "enable-benchmarks-write",
"enable-benchmarks-udf-sub", "enable-benchmarks-storage",
"enable-benchmarks-fabric", "enable-benchmarks-ops-sub":
return true

default:
return false
}
}

// isSpecialStringField returns true if the passed key
// in aerospike config is string type field but can have
// bool value also
Expand Down

0 comments on commit 8da3bde

Please sign in to comment.