753 reverting autogen rule changes
@@ -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
-}
