1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-30 03:15:05 +00:00

753 practical test fixes

This commit is contained in:
shravan 2020-04-04 16:18:36 +05:30
parent dd0f3d140e
commit d4baf44fd9

View file

@ -56,7 +56,7 @@ func Validate(policyRaw []byte, client *dclient.Client, mock bool, openAPIContro
}
if doesMatchAndExcludeConflict(rule) {
return fmt.Errorf("path: spec.rules[%d]: rule is matching an empty set", i)
return fmt.Errorf("path: spec.rules[%v]: rule is matching an empty set", rule.Name)
}
// validate rule actions
@ -94,6 +94,14 @@ func Validate(policyRaw []byte, client *dclient.Client, mock bool, openAPIContro
// of match and exclude block is not an empty set
func doesMatchAndExcludeConflict(rule kyverno.Rule) bool {
if reflect.DeepEqual(rule.MatchResources, kyverno.MatchResources{}) {
return true
}
if reflect.DeepEqual(rule.ExcludeResources, kyverno.ExcludeResources{}) {
return false
}
excludeRoles := make(map[string]bool)
for _, role := range rule.ExcludeResources.UserInfo.Roles {
excludeRoles[role] = true