mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-05 07:26:55 +00:00
753 final fixes
This commit is contained in:
parent
d4baf44fd9
commit
2599b29a09
1 changed files with 15 additions and 2 deletions
|
@ -302,10 +302,10 @@ func generateRuleForControllers(rule kyverno.Rule, controllers string, log logr.
|
||||||
}
|
}
|
||||||
|
|
||||||
// overwrite Kinds by pod controllers defined in the annotation
|
// overwrite Kinds by pod controllers defined in the annotation
|
||||||
controllerRule.MatchResources.Kinds = strings.Split(controllers, ",")
|
controllerRule.MatchResources.Kinds = replacePodWithPodControllers(controllerRule.MatchResources.Kinds, strings.Split(controllers, ","))
|
||||||
if len(exclude.Kinds) != 0 {
|
if len(exclude.Kinds) != 0 {
|
||||||
controllerRule.ExcludeResources = exclude.DeepCopy()
|
controllerRule.ExcludeResources = exclude.DeepCopy()
|
||||||
controllerRule.ExcludeResources.Kinds = strings.Split(controllers, ",")
|
controllerRule.ExcludeResources.Kinds = replacePodWithPodControllers(controllerRule.ExcludeResources.Kinds, strings.Split(controllers, ","))
|
||||||
}
|
}
|
||||||
|
|
||||||
if rule.Mutation.Overlay != nil {
|
if rule.Mutation.Overlay != nil {
|
||||||
|
@ -395,3 +395,16 @@ func defaultPodControllerAnnotation(ann map[string]string) ([]byte, error) {
|
||||||
}
|
}
|
||||||
return patchByte, nil
|
return patchByte, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func replacePodWithPodControllers(kinds []string, controllers []string) []string {
|
||||||
|
|
||||||
|
var kindsWithoutPod []string
|
||||||
|
for _, kind := range kinds {
|
||||||
|
if strings.ToLower(kind) == "pod" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
kindsWithoutPod = append(kindsWithoutPod, kind)
|
||||||
|
}
|
||||||
|
|
||||||
|
return append(kindsWithoutPod, controllers...)
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue