mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-31 03:45:17 +00:00
fix: creating ClusterAdmissionReports fails for resources with colon in name (#8530)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
parent
7add300ffa
commit
15630ffaaa
2 changed files with 16 additions and 8 deletions
pkg/utils
|
@ -58,6 +58,14 @@ func SetAnnotation(obj metav1.Object, key, value string) {
|
||||||
obj.SetAnnotations(annotations)
|
obj.SetAnnotations(annotations)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetAnnotation(obj metav1.Object, key string) string {
|
||||||
|
annotations := obj.GetAnnotations()
|
||||||
|
if annotations == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return annotations[key]
|
||||||
|
}
|
||||||
|
|
||||||
func HasAnnotation(obj metav1.Object, key string) bool {
|
func HasAnnotation(obj metav1.Object, key string) bool {
|
||||||
annotations := obj.GetAnnotations()
|
annotations := obj.GetAnnotations()
|
||||||
if annotations == nil {
|
if annotations == nil {
|
||||||
|
|
|
@ -21,11 +21,11 @@ import (
|
||||||
const (
|
const (
|
||||||
LabelDomain = "kyverno.io"
|
LabelDomain = "kyverno.io"
|
||||||
// resource labels
|
// resource labels
|
||||||
LabelResourceHash = "audit.kyverno.io/resource.hash"
|
LabelResourceHash = "audit.kyverno.io/resource.hash"
|
||||||
LabelResourceUid = "audit.kyverno.io/resource.uid"
|
LabelResourceUid = "audit.kyverno.io/resource.uid"
|
||||||
LabelResourceGVR = "audit.kyverno.io/resource.gvr"
|
LabelResourceGVR = "audit.kyverno.io/resource.gvr"
|
||||||
LabelResourceNamespace = "audit.kyverno.io/resource.namespace"
|
AnnotationResourceNamespace = "audit.kyverno.io/resource.namespace"
|
||||||
LabelResourceName = "audit.kyverno.io/resource.name"
|
AnnotationResourceName = "audit.kyverno.io/resource.name"
|
||||||
// policy labels
|
// policy labels
|
||||||
LabelDomainClusterPolicy = "cpol.kyverno.io"
|
LabelDomainClusterPolicy = "cpol.kyverno.io"
|
||||||
LabelDomainPolicy = "pol.kyverno.io"
|
LabelDomainPolicy = "pol.kyverno.io"
|
||||||
|
@ -99,8 +99,8 @@ func SetResourceGVR(report kyvernov1alpha2.ReportInterface, gvr schema.GroupVers
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetResourceNamespaceAndName(report kyvernov1alpha2.ReportInterface, namespace, name string) {
|
func SetResourceNamespaceAndName(report kyvernov1alpha2.ReportInterface, namespace, name string) {
|
||||||
controllerutils.SetLabel(report, LabelResourceNamespace, namespace)
|
controllerutils.SetAnnotation(report, AnnotationResourceNamespace, namespace)
|
||||||
controllerutils.SetLabel(report, LabelResourceName, name)
|
controllerutils.SetAnnotation(report, AnnotationResourceName, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CalculateResourceHash(resource unstructured.Unstructured) string {
|
func CalculateResourceHash(resource unstructured.Unstructured) string {
|
||||||
|
@ -152,7 +152,7 @@ func GetResourceGVR(report metav1.Object) schema.GroupVersionResource {
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetResourceNamespaceAndName(report kyvernov1alpha2.ReportInterface) (string, string) {
|
func GetResourceNamespaceAndName(report kyvernov1alpha2.ReportInterface) (string, string) {
|
||||||
return controllerutils.GetLabel(report, LabelResourceNamespace), controllerutils.GetLabel(report, LabelResourceName)
|
return controllerutils.GetAnnotation(report, AnnotationResourceNamespace), controllerutils.GetAnnotation(report, AnnotationResourceName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetResourceHash(report metav1.Object) string {
|
func GetResourceHash(report metav1.Object) string {
|
||||||
|
|
Loading…
Add table
Reference in a new issue