in pkg/config/config.go [188:215]
func overrideMetadataPathsWithPlaceholders() {
valueToPlaceholderPathsKeyMap := GetMetadataValueToPlaceholderPathsKeyMap()
_, valueDefaults := GetMetadataDefaults()
// override placeholders in paths, precedence is applied in the following order:
// (1) placeholder value in metadata path itself is overridden with a non-default value
// (2) placeholder value represented as metadata value is overridden
// (3) default value for the placeholder
for mdValueKey, listOfPaths := range valueToPlaceholderPathsKeyMap {
defaultValue := valueDefaults[mdValueKey].(string)
overriddenValue := viper.Get(mdValueKey).(string)
// apply (1) and (2) from above
if defaultValue != overriddenValue {
for _, pathKey := range listOfPaths {
// get current path value
switch currentPath := viper.Get(pathKey).(type) {
case string:
// find default value and replace with overridden value
updatedPath := strings.Replace(currentPath, defaultValue, overriddenValue, -1)
// set new path value
log.Printf("Updating path from %s to %s\n", currentPath, updatedPath)
viper.Set(pathKey, updatedPath)
default:
log.Printf("Something went wrong trying to update path. Expected type 'string' for %v\n", currentPath)
}
}
}
}
}