mirror of
https://github.com/prymitive/karma
synced 2026-05-05 03:16:51 +00:00
feat(backend): fail on unknown keys in ACL config file
This commit is contained in:
committed by
Łukasz Mierzwa
parent
bb5a5a4e14
commit
940eacd0ea
36
cmd/karma/tests/testscript/074_acl_extra_fileds.txt
Normal file
36
cmd/karma/tests/testscript/074_acl_extra_fileds.txt
Normal file
@@ -0,0 +1,36 @@
|
||||
# Raises an error if --authorization.acl points to a file that contains unknown keys
|
||||
karma.bin-should-fail --log.format=text --log.config=false --check-config
|
||||
! stdout .
|
||||
! stderr 'msg="Configuration is valid"'
|
||||
stderr 'msg="Reading silence ACL config file acl.yaml"'
|
||||
stderr 'msg="Failed to parse silence ACL configuration file \\"acl.yaml\\": yaml: unmarshal errors:\\n line 6: field nameFoo not found in type config.SilenceFilters"'
|
||||
|
||||
-- karma.yaml --
|
||||
authentication:
|
||||
header:
|
||||
name: "X-User"
|
||||
value_re: "(.+)"
|
||||
authorization:
|
||||
groups:
|
||||
- name: admins
|
||||
members:
|
||||
- alice
|
||||
- bob
|
||||
- name: users
|
||||
members:
|
||||
- john
|
||||
acl:
|
||||
silences: acl.yaml
|
||||
alertmanager:
|
||||
servers:
|
||||
- name: default
|
||||
uri: https://localhost:9093
|
||||
|
||||
-- acl.yaml --
|
||||
rules:
|
||||
- action: block
|
||||
reason: prod cluster cannot be silenced
|
||||
scope:
|
||||
filters:
|
||||
- nameFoo: cluster
|
||||
value: prod
|
||||
@@ -52,7 +52,7 @@ func ReadSilenceACLConfig(path string) (*silencesACLSchema, error) {
|
||||
return nil, fmt.Errorf("Failed to load silence ACL configuration file %q: %v", path, err)
|
||||
}
|
||||
|
||||
err = yaml.Unmarshal(f, &cfg)
|
||||
err = yaml.UnmarshalStrict(f, &cfg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to parse silence ACL configuration file %q: %v", path, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user