make sure to set relevant config entries correctly (#17485)

Bonus: also allow skipping keys properly.
This commit is contained in:
Harshavardhana
2023-06-22 10:04:02 -07:00
committed by GitHub
parent 82ce78a17c
commit 74759b05a5
3 changed files with 30 additions and 17 deletions

View File

@@ -598,7 +598,7 @@ func LookupSite(siteKV KVS, regionKV KVS) (s Site, err error) {
// CheckValidKeys - checks if inputs KVS has the necessary keys,
// returns error if it find extra or superflous keys.
func CheckValidKeys(subSys string, kv KVS, validKVS KVS) error {
func CheckValidKeys(subSys string, kv KVS, validKVS KVS, deprecatedKeys ...string) error {
nkv := KVS{}
for _, kv := range kv {
// Comment is a valid key, its also fully optional
@@ -607,6 +607,16 @@ func CheckValidKeys(subSys string, kv KVS, validKVS KVS) error {
if kv.Key == Comment {
continue
}
var skip bool
for _, deprecatedKey := range deprecatedKeys {
if kv.Key == deprecatedKey {
skip = true
break
}
}
if skip {
continue
}
if _, ok := validKVS.Lookup(kv.Key); !ok {
nkv = append(nkv, kv)
}