mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-28 10:28:36 +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
|
@ -58,6 +58,14 @@ func SetAnnotation(obj metav1.Object, key, value string) {
|
|||
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 {
|
||||
annotations := obj.GetAnnotations()
|
||||
if annotations == nil {
|
||||
|
|
|
@ -21,11 +21,11 @@ import (
|
|||
const (
|
||||
LabelDomain = "kyverno.io"
|
||||
// resource labels
|
||||
LabelResourceHash = "audit.kyverno.io/resource.hash"
|
||||
LabelResourceUid = "audit.kyverno.io/resource.uid"
|
||||
LabelResourceGVR = "audit.kyverno.io/resource.gvr"
|
||||
LabelResourceNamespace = "audit.kyverno.io/resource.namespace"
|
||||
LabelResourceName = "audit.kyverno.io/resource.name"
|
||||
LabelResourceHash = "audit.kyverno.io/resource.hash"
|
||||
LabelResourceUid = "audit.kyverno.io/resource.uid"
|
||||
LabelResourceGVR = "audit.kyverno.io/resource.gvr"
|
||||
AnnotationResourceNamespace = "audit.kyverno.io/resource.namespace"
|
||||
AnnotationResourceName = "audit.kyverno.io/resource.name"
|
||||
// policy labels
|
||||
LabelDomainClusterPolicy = "cpol.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) {
|
||||
controllerutils.SetLabel(report, LabelResourceNamespace, namespace)
|
||||
controllerutils.SetLabel(report, LabelResourceName, name)
|
||||
controllerutils.SetAnnotation(report, AnnotationResourceNamespace, namespace)
|
||||
controllerutils.SetAnnotation(report, AnnotationResourceName, name)
|
||||
}
|
||||
|
||||
func CalculateResourceHash(resource unstructured.Unstructured) string {
|
||||
|
@ -152,7 +152,7 @@ func GetResourceGVR(report metav1.Object) schema.GroupVersionResource {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue