mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
753 reverting autogen rule changes
This commit is contained in:
parent
23d2a215dc
commit
09b3172b8c
1 changed files with 2 additions and 29 deletions
|
@ -4,7 +4,6 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
|
@ -303,10 +302,10 @@ func generateRuleForControllers(rule kyverno.Rule, controllers string, log logr.
|
|||
}
|
||||
|
||||
// overwrite Kinds by pod controllers defined in the annotation
|
||||
controllerRule.MatchResources.Kinds = replacePodWithPodControllers(controllerRule.MatchResources.Kinds, strings.Split(controllers, ","))
|
||||
controllerRule.MatchResources.Kinds = strings.Split(controllers, ",")
|
||||
if len(exclude.Kinds) != 0 {
|
||||
controllerRule.ExcludeResources = exclude.DeepCopy()
|
||||
controllerRule.ExcludeResources.Kinds = replacePodWithPodControllers(controllerRule.ExcludeResources.Kinds, strings.Split(controllers, ","))
|
||||
controllerRule.ExcludeResources.Kinds = strings.Split(controllers, ",")
|
||||
}
|
||||
|
||||
if rule.Mutation.Overlay != nil {
|
||||
|
@ -396,29 +395,3 @@ func defaultPodControllerAnnotation(ann map[string]string) ([]byte, error) {
|
|||
}
|
||||
return patchByte, nil
|
||||
}
|
||||
|
||||
func replacePodWithPodControllers(kinds []string, controllers []string) []string {
|
||||
|
||||
kindMap := make(map[string]bool)
|
||||
|
||||
for _, kind := range kinds {
|
||||
kindMap[kind] = true
|
||||
}
|
||||
|
||||
delete(kindMap, "Pod")
|
||||
|
||||
for _, controller := range controllers {
|
||||
kindMap[controller] = true
|
||||
}
|
||||
|
||||
output := make([]string, 0, len(kindMap))
|
||||
for kind := range kindMap {
|
||||
output = append(output, kind)
|
||||
}
|
||||
|
||||
sort.Slice(output, func(i, j int) bool {
|
||||
return output[i] < output[j]
|
||||
})
|
||||
|
||||
return output
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue