@@ -34,10 +34,10 @@ const (
3434 EventCreated = "CREATED"
3535 // EventDeleted indicates that a pod has been deleted.
3636 EventDeleted = "DELETED"
37- // RuntimeRiskAnnotationKey represents the annotation key for runtime risks .
38- RuntimeRiskAnnotationKey = "metadata.github.com/runtime-risks "
39- // CustomTagAnnotationKeyPrefix is the annotation key prefix for custom tags .
40- CustomTagAnnotationKeyPrefix = "metadata.github.com/ "
37+ // MetadataAnnotationPrefix is the annotation key prefix for deployment record metadata like runtime risk and tags .
38+ MetadataAnnotationPrefix = "metadata.github.com/"
39+ // RuntimeRisksAnnotationKey is the tag key for runtime risks. Comes after MetadataAnnotationPrefix .
40+ RuntimeRisksAnnotationKey = "runtime-risks "
4141 // MaxCustomTags is the maximum number of custom tags per deployment record.
4242 MaxCustomTags = 5
4343 // MaxCustomTagLength is the maximum length for a custom tag key or value.
@@ -733,7 +733,7 @@ func extractMetadataFromObject(obj *metav1.PartialObjectMetadata, aggPodMetadata
733733 annotations := obj .GetAnnotations ()
734734
735735 // Extract runtime risks
736- if risks , exists := annotations [RuntimeRiskAnnotationKey ]; exists {
736+ if risks , exists := annotations [MetadataAnnotationPrefix + RuntimeRisksAnnotationKey ]; exists {
737737 for _ , risk := range strings .Split (risks , "," ) {
738738 r := deploymentrecord .ValidateRuntimeRisk (risk )
739739 if r != "" {
@@ -754,12 +754,15 @@ func extractMetadataFromObject(obj *metav1.PartialObjectMetadata, aggPodMetadata
754754 if len (aggPodMetadata .Tags ) >= MaxCustomTags {
755755 break
756756 }
757- if RuntimeRiskAnnotationKey == key {
758- continue
759- }
760- if strings .HasPrefix (key , CustomTagAnnotationKeyPrefix ) {
761- tagKey := strings .TrimPrefix (key , CustomTagAnnotationKeyPrefix )
757+
758+ if strings .HasPrefix (key , MetadataAnnotationPrefix ) {
759+ tagKey := strings .TrimPrefix (key , MetadataAnnotationPrefix )
762760 tagValue := annotations [key ]
761+
762+ if RuntimeRisksAnnotationKey == tagKey {
763+ // ignore runtime risks for custom tags
764+ continue
765+ }
763766 if utf8 .RuneCountInString (tagKey ) > MaxCustomTagLength || utf8 .RuneCountInString (tagValue ) > MaxCustomTagLength {
764767 slog .Warn ("Tag key or value exceeds max length, skipping" ,
765768 "object_name" , obj .GetName (),
0 commit comments