mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-31 03:45:17 +00:00
Merge pull request #252 from nirmata/251_bug
update arguments & cleanup print
This commit is contained in:
commit
2200f9c784
2 changed files with 4 additions and 4 deletions
|
@ -227,7 +227,7 @@ spec:
|
||||||
containers:
|
containers:
|
||||||
- name: kyverno
|
- name: kyverno
|
||||||
image: nirmata/kyverno:latest
|
image: nirmata/kyverno:latest
|
||||||
args: ["--filterK8Resources","[Event,*,*][*,kube-system,*][*,kube-public,*][*,kube-node-lease,*]Node,*,*][APIService,*,*][TokenReview,*,*][SubjectAccessReview,*,*][Deployment,default,nginx-deployment]"]
|
args: ["--filterK8Resources","[Event,*,*][*,kube-system,*][*,kube-public,*][*,kube-node-lease,*]Node,*,*][APIService,*,*][TokenReview,*,*][SubjectAccessReview,*,*][*,kyverno,*]"]
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 443
|
- containerPort: 443
|
||||||
securityContext:
|
securityContext:
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -24,6 +23,7 @@ type K8Resource struct {
|
||||||
Name string
|
Name string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//SkipFilteredResourcesReq checks if request is to be skipped based on filtered kinds
|
||||||
func SkipFilteredResourcesReq(request *v1beta1.AdmissionRequest, filterK8Resources []K8Resource) bool {
|
func SkipFilteredResourcesReq(request *v1beta1.AdmissionRequest, filterK8Resources []K8Resource) bool {
|
||||||
kind := request.Kind.Kind
|
kind := request.Kind.Kind
|
||||||
namespace := request.Namespace
|
namespace := request.Namespace
|
||||||
|
@ -36,6 +36,7 @@ func SkipFilteredResourcesReq(request *v1beta1.AdmissionRequest, filterK8Resourc
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//SkipFilteredResources checks if the resource is to be skipped based on filtered kinds
|
||||||
func SkipFilteredResources(kind, namespace, name string, filterK8Resources []K8Resource) bool {
|
func SkipFilteredResources(kind, namespace, name string, filterK8Resources []K8Resource) bool {
|
||||||
for _, r := range filterK8Resources {
|
for _, r := range filterK8Resources {
|
||||||
if wildcard.Match(r.Kind, kind) && wildcard.Match(r.Namespace, namespace) && wildcard.Match(r.Name, name) {
|
if wildcard.Match(r.Kind, kind) && wildcard.Match(r.Namespace, namespace) && wildcard.Match(r.Name, name) {
|
||||||
|
@ -45,7 +46,7 @@ func SkipFilteredResources(kind, namespace, name string, filterK8Resources []K8R
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
//parseKinds parses the kinds if a single string contains comma seperated kinds
|
//ParseKinds parses the kinds if a single string contains comma seperated kinds
|
||||||
// {"1,2,3","4","5"} => {"1","2","3","4","5"}
|
// {"1,2,3","4","5"} => {"1","2","3","4","5"}
|
||||||
func ParseKinds(list string) []K8Resource {
|
func ParseKinds(list string) []K8Resource {
|
||||||
resources := []K8Resource{}
|
resources := []K8Resource{}
|
||||||
|
@ -69,7 +70,6 @@ func ParseKinds(list string) []K8Resource {
|
||||||
if len(elements) == 1 {
|
if len(elements) == 1 {
|
||||||
resource = K8Resource{Kind: elements[0]}
|
resource = K8Resource{Kind: elements[0]}
|
||||||
}
|
}
|
||||||
fmt.Println(resource)
|
|
||||||
resources = append(resources, resource)
|
resources = append(resources, resource)
|
||||||
}
|
}
|
||||||
return resources
|
return resources
|
||||||
|
|
Loading…
Add table
Reference in a new issue