[ARVADOS] created: 2.1.0-920-g4e65a41be
Git user
git at public.arvados.org
Sun Jun 13 14:01:49 UTC 2021
at 4e65a41bea4b892ef7232bfe6b9b20ca35380368 (commit)
commit 4e65a41bea4b892ef7232bfe6b9b20ca35380368
Author: Tom Clegg <tom at curii.com>
Date: Sun Jun 13 10:00:45 2021 -0400
17803: Warn when config keys are ignored due to case mismatch.
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>
diff --git a/lib/config/load.go b/lib/config/load.go
index cc26cdaec..73f0a2445 100644
--- a/lib/config/load.go
+++ b/lib/config/load.go
@@ -354,20 +354,24 @@ func (ldr *Loader) logExtraKeys(expected, supplied map[string]interface{}, prefi
if ldr.Logger == nil {
return
}
- allowed := map[string]interface{}{}
- for k, v := range expected {
- allowed[strings.ToLower(k)] = v
- }
for k, vsupp := range supplied {
if k == "SAMPLE" {
// entry will be dropped in removeSampleKeys anyway
continue
}
- vexp, ok := allowed[strings.ToLower(k)]
+ vexp, ok := expected[k]
if expected["SAMPLE"] != nil {
vexp = expected["SAMPLE"]
} else if !ok {
- ldr.Logger.Warnf("deprecated or unknown config entry: %s%s", prefix, k)
+ // check for a case-insensitive match
+ hint := ""
+ for ek := range expected {
+ if strings.EqualFold(k, ek) {
+ hint = " (perhaps you meant " + ek + "?)"
+ break
+ }
+ }
+ ldr.Logger.Warnf("deprecated or unknown config entry: %s%s%s", prefix, k, hint)
continue
}
if vsupp, ok := vsupp.(map[string]interface{}); !ok {
diff --git a/lib/config/load_test.go b/lib/config/load_test.go
index 6c11ee780..9d3258c19 100644
--- a/lib/config/load_test.go
+++ b/lib/config/load_test.go
@@ -196,9 +196,10 @@ Clusters:
SystemRootToken: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Collections:
BlobSigningKey: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
- postgresql: {}
+ PostgreSQL: {}
BadKey: {}
- Containers: {}
+ Containers:
+ RunTimeEngine: abc
RemoteClusters:
z2222:
Host: z2222.arvadosapi.com
@@ -206,11 +207,12 @@ Clusters:
BadKey: badValue
`, &logbuf).Load()
c.Assert(err, check.IsNil)
+ c.Log(logbuf.String())
logs := strings.Split(strings.TrimSuffix(logbuf.String(), "\n"), "\n")
for _, log := range logs {
- c.Check(log, check.Matches, `.*deprecated or unknown config entry:.*BadKey.*`)
+ c.Check(log, check.Matches, `.*deprecated or unknown config entry:.*(RunTimeEngine.*RuntimeEngine|BadKey).*`)
}
- c.Check(logs, check.HasLen, 2)
+ c.Check(logs, check.HasLen, 3)
}
func (s *LoadSuite) checkSAMPLEKeys(c *check.C, path string, x interface{}) {
@@ -322,7 +324,7 @@ func (s *LoadSuite) TestPostgreSQLKeyConflict(c *check.C) {
_, err := testLoader(c, `
Clusters:
zzzzz:
- postgresql:
+ PostgreSQL:
connection:
DBName: dbname
Host: host
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list