mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-14 11:48:53 +00:00
* Fix wildcard issue Co-Authored-By: vyankd <51167361+vyankd@users.noreply.github.com> * Delete res.yaml Co-Authored-By: vyankd <51167361+vyankd@users.noreply.github.com> Co-authored-by: vyankd <51167361+vyankd@users.noreply.github.com> Co-authored-by: vyankd <51167361+vyankd@users.noreply.github.com>
This commit is contained in:
parent
f2b63cef77
commit
f2dde173ce
4 changed files with 21 additions and 1 deletions
|
@ -29,6 +29,18 @@ func formatSubresource(s string) string {
|
||||||
return strings.Replace(s, ".", "/", 1)
|
return strings.Replace(s, ".", "/", 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetGroupFromGVK - get group GVK
|
||||||
|
func GetGroupFromGVK(str string) (group string) {
|
||||||
|
parts := strings.Split(str, "/")
|
||||||
|
count := len(parts)
|
||||||
|
if count == 3 {
|
||||||
|
if parts[1] == "*" {
|
||||||
|
return parts[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func SplitSubresource(s string) (kind string, subresource string) {
|
func SplitSubresource(s string) (kind string, subresource string) {
|
||||||
normalized := strings.Replace(s, ".", "/", 1)
|
normalized := strings.Replace(s, ".", "/", 1)
|
||||||
parts := strings.Split(normalized, "/")
|
parts := strings.Split(normalized, "/")
|
||||||
|
|
|
@ -795,7 +795,8 @@ func (m *webhookConfigManager) mergeWebhook(dst *webhook, policy kyverno.PolicyI
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if strings.Contains(gvk, "*") {
|
if strings.Contains(gvk, "*") {
|
||||||
gvrList = append(gvrList, schema.GroupVersionResource{Group: gvr.Group, Version: "*", Resource: gvr.Resource})
|
group := kubeutils.GetGroupFromGVK(gvk)
|
||||||
|
gvrList = append(gvrList, schema.GroupVersionResource{Group: group, Version: "*", Resource: gvr.Resource})
|
||||||
} else {
|
} else {
|
||||||
m.log.V(4).Info("configuring webhook", "GVK", gvk, "GVR", gvr)
|
m.log.V(4).Info("configuring webhook", "GVK", gvk, "GVR", gvr)
|
||||||
gvrList = append(gvrList, gvr)
|
gvrList = append(gvrList, gvr)
|
||||||
|
|
|
@ -3,6 +3,7 @@ policies:
|
||||||
- image-example.yaml
|
- image-example.yaml
|
||||||
resources:
|
resources:
|
||||||
- resources.yaml
|
- resources.yaml
|
||||||
|
variables: values.yaml
|
||||||
results:
|
results:
|
||||||
- policy: images
|
- policy: images
|
||||||
rule: only-allow-trusted-images
|
rule: only-allow-trusted-images
|
||||||
|
|
6
test/cli/registry/values.yaml
Normal file
6
test/cli/registry/values.yaml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
policies:
|
||||||
|
- name: check-image-base
|
||||||
|
rules:
|
||||||
|
- name: check-image-base-rule
|
||||||
|
foreachValues:
|
||||||
|
mobysource: ["1"]
|
Loading…
Add table
Reference in a new issue