mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-27 15:08:14 +02:00
fix unused key warnings in routes (#3711)
This commit is contained in:
parent
3f9dfbef76
commit
d8f4355f66
1 changed files with 7 additions and 1 deletions
|
@ -11,6 +11,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -403,10 +404,15 @@ func optionsFromViper(configFile string) (*Options, error) {
|
||||||
return o, nil
|
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) {
|
func checkUnusedConfigFields(configFile string, unused []string) {
|
||||||
keys := make([]string, 0, len(unused))
|
keys := make([]string, 0, len(unused))
|
||||||
for _, k := range 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)
|
keys = append(keys, k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue