From d8f4355f66e90c66e8a339c41d4baf713a07fdfc Mon Sep 17 00:00:00 2001 From: Denis Mishin Date: Fri, 28 Oct 2022 14:59:43 -0400 Subject: [PATCH] fix unused key warnings in routes (#3711) --- config/options.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/config/options.go b/config/options.go index 5a128f45e..916f287a1 100644 --- a/config/options.go +++ b/config/options.go @@ -11,6 +11,7 @@ import ( "os" "path/filepath" "reflect" + "regexp" "strings" "time" @@ -403,10 +404,15 @@ func optionsFromViper(configFile string) (*Options, error) { return o, nil } +var ( + // policy's embedded protobuf structs are decoded by separate hook and are unknown to mapstructure + routesEmbeddedFieldsRe = regexp.MustCompile(`(routes|policy)\[\.*`) +) + func checkUnusedConfigFields(configFile string, unused []string) { keys := make([]string, 0, len(unused)) for _, k := range unused { - if !strings.HasPrefix(k, "policy[") { // policy's embedded protobuf structs are decoded by separate hook and are unknown to mapstructure + if !routesEmbeddedFieldsRe.MatchString(k) { keys = append(keys, k) } }