Skip to content

Commit

Permalink
exporting more functions
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmayja committed Apr 14, 2024
1 parent 0110ff0 commit a11e7fe
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
20 changes: 8 additions & 12 deletions asconfig/as_setconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ func rearrangeConfigMap(log logr.Logger, configMap DynamicConfigMap) []string {
// If namespace is removed, directly add it to the final list
finalList = append(finalList, k)
} else {
// If namespace is added, add it after all DCs and their direct fields
// If namespace is added, add it after all DCs and their direct configs
if lastDCConfig == nil {
if lastDC != nil {
rearrangedConfigMap.InsertAfter(k, lastDC)
Expand All @@ -419,23 +419,19 @@ func rearrangeConfigMap(log logr.Logger, configMap DynamicConfigMap) []string {
// Handle DC direct fields
if tokens[len(tokens)-3] == info.ConfigDCContext {
var nap *list.Element
// Check if the key is related to 'node-address-ports'
isNodeAddressPortsKey := strings.HasSuffix(k, sep+keyNodeAddressPorts)

if isNodeAddressPortsKey {
// Check if the key is 'node-address-ports'
if strings.HasSuffix(k, sep+keyNodeAddressPorts) {
if _, ok := v[Remove]; ok {
dc := rearrangedConfigMap.PushFront(k)
if lastDC == nil {
lastDC = dc
}
continue
} else {
if lastDCConfig != nil {
// Add 'node-address-ports' after all DC direct fields
// There are certain fields that must be set before 'node-address-ports', for example, 'tls-name'.
lastDCConfig = rearrangedConfigMap.InsertAfter(k, lastDCConfig)
continue
}
} else if lastDCConfig != nil {
// Add 'node-address-ports' after all DC direct fields
// There are certain fields that must be set before 'node-address-ports', for example, 'tls-name'.
lastDCConfig = rearrangedConfigMap.InsertAfter(k, lastDCConfig)
continue
}
}

Expand Down
7 changes: 4 additions & 3 deletions asconfig/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package asconfig
import (
"encoding/json"
"fmt"
"github.com/aerospike/aerospike-management-lib/info"
"os"
"path/filepath"
"reflect"
Expand All @@ -13,6 +12,8 @@ import (

sets "github.com/deckarep/golang-set/v2"
"github.com/go-logr/logr"

"github.com/aerospike/aerospike-management-lib/info"
)

// map of version to schema
Expand Down Expand Up @@ -222,14 +223,14 @@ func IsDynamicConfig(log logr.Logger, dynamic sets.Set[string], conf string,
}
}

return dynamic.Contains(getFlatKey(tokens))
return dynamic.Contains(GetFlatKey(tokens))
}

// getDefaultValue returns the default value of a particular config
func getDefaultValue(defaultMap map[string]interface{}, conf string) interface{} {
tokens := strings.Split(conf, ".")

return defaultMap[getFlatKey(tokens)]
return defaultMap[GetFlatKey(tokens)]
}

// GetDefault return the map of default values.
Expand Down
2 changes: 1 addition & 1 deletion asconfig/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ func getContextAndName(log logr.Logger, key, _ string) (context, name string) {
return strings.Trim(ctx, "/"), keys[len(keys)-1]
}

func getFlatKey(tokens []string) string {
func GetFlatKey(tokens []string) string {
var key string

for _, token := range tokens {
Expand Down

0 comments on commit a11e7fe

Please sign in to comment.