diff options
| author | James Elliott <james-d-elliott@users.noreply.github.com> | 2022-06-28 13:15:50 +1000 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-28 13:15:50 +1000 | 
| commit | d2f1e5d36de9e271d0c668a7323b9e876812e6a2 (patch) | |
| tree | 794d9b0b7ca2651a559ded58491a0aa1453a169c /internal/configuration/provider.go | |
| parent | ab1d0c51d31e423f3caf4da1e02f3cc863c2cbd9 (diff) | |
feat(configuration): automatically map old keys (#3199)
This performs automatic remapping of deprecated configuration keys in most situations.
Diffstat (limited to 'internal/configuration/provider.go')
| -rw-r--r-- | internal/configuration/provider.go | 21 | 
1 files changed, 17 insertions, 4 deletions
diff --git a/internal/configuration/provider.go b/internal/configuration/provider.go index b64bb8bc1..111e5c041 100644 --- a/internal/configuration/provider.go +++ b/internal/configuration/provider.go @@ -29,14 +29,27 @@ func LoadAdvanced(val *schema.StructValidator, path string, result interface{},  		StrictMerge: false,  	}) -	err = loadSources(ko, val, sources...) -	if err != nil { +	if err = loadSources(ko, val, sources...); err != nil {  		return ko.Keys(), err  	} -	unmarshal(ko, val, path, result) +	var final *koanf.Koanf -	return getAllKoanfKeys(ko), nil +	if final, err = koanfRemapKeys(val, ko, deprecations); err != nil { +		return koanfGetKeys(ko), err +	} + +	unmarshal(final, val, path, result) + +	return koanfGetKeys(final), nil +} + +func mapHasKey(k string, m map[string]interface{}) bool { +	if _, ok := m[k]; ok { +		return true +	} + +	return false  }  func unmarshal(ko *koanf.Koanf, val *schema.StructValidator, path string, o interface{}) {  | 
