diff --git a/asconfig/conffilereader.go b/asconfig/conffilereader.go index e8d53a0..28754f9 100644 --- a/asconfig/conffilereader.go +++ b/asconfig/conffilereader.go @@ -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 } diff --git a/asconfig/conffilewriter.go b/asconfig/conffilewriter.go index d33de3a..2c947e1 100644 --- a/asconfig/conffilewriter.go +++ b/asconfig/conffilewriter.go @@ -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") diff --git a/asconfig/utils.go b/asconfig/utils.go index 348c402..117f535 100644 --- a/asconfig/utils.go +++ b/asconfig/utils.go @@ -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