From ad653a63b30bd69cf2f4085190fbdfbfa182ce83 Mon Sep 17 00:00:00 2001 From: Valerian Roche Date: Wed, 9 Jul 2025 04:05:41 -0400 Subject: [PATCH] feat: use common annotation prefix to simplify filtering in informer transformers (#5621) In order to filter annotations in informer transformers, this PR makes it more explicit that a common prefix is used. New prefixes can be added later-on if need be, but all annotations should be anchored in a known prefix. Signed-off-by: Valerian Roche --- source/annotations/annotations.go | 40 +++++++++++++++++-------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/source/annotations/annotations.go b/source/annotations/annotations.go index bd21ca2bc..abfce1359 100644 --- a/source/annotations/annotations.go +++ b/source/annotations/annotations.go @@ -18,37 +18,41 @@ import ( ) const ( + // AnnotationKeyPrefix is set on all annotations consumed by external-dns (outside of user templates) + // to provide easy filtering. + AnnotationKeyPrefix = "external-dns.alpha.kubernetes.io/" + // CloudflareProxiedKey The annotation used for determining if traffic will go through Cloudflare - CloudflareProxiedKey = "external-dns.alpha.kubernetes.io/cloudflare-proxied" - CloudflareCustomHostnameKey = "external-dns.alpha.kubernetes.io/cloudflare-custom-hostname" - CloudflareRegionKey = "external-dns.alpha.kubernetes.io/cloudflare-region-key" - CloudflareRecordCommentKey = "external-dns.alpha.kubernetes.io/cloudflare-record-comment" + CloudflareProxiedKey = AnnotationKeyPrefix + "cloudflare-proxied" + CloudflareCustomHostnameKey = AnnotationKeyPrefix + "cloudflare-custom-hostname" + CloudflareRegionKey = AnnotationKeyPrefix + "cloudflare-region-key" + CloudflareRecordCommentKey = AnnotationKeyPrefix + "cloudflare-record-comment" - AWSPrefix = "external-dns.alpha.kubernetes.io/aws-" - SCWPrefix = "external-dns.alpha.kubernetes.io/scw-" - WebhookPrefix = "external-dns.alpha.kubernetes.io/webhook-" - CloudflarePrefix = "external-dns.alpha.kubernetes.io/cloudflare-" + AWSPrefix = AnnotationKeyPrefix + "aws-" + SCWPrefix = AnnotationKeyPrefix + "scw-" + WebhookPrefix = AnnotationKeyPrefix + "webhook-" + CloudflarePrefix = AnnotationKeyPrefix + "cloudflare-" - TtlKey = "external-dns.alpha.kubernetes.io/ttl" + TtlKey = AnnotationKeyPrefix + "ttl" ttlMinimum = 1 ttlMaximum = math.MaxInt32 - SetIdentifierKey = "external-dns.alpha.kubernetes.io/set-identifier" - AliasKey = "external-dns.alpha.kubernetes.io/alias" - TargetKey = "external-dns.alpha.kubernetes.io/target" + SetIdentifierKey = AnnotationKeyPrefix + "set-identifier" + AliasKey = AnnotationKeyPrefix + "alias" + TargetKey = AnnotationKeyPrefix + "target" // The annotation used for figuring out which controller is responsible - ControllerKey = "external-dns.alpha.kubernetes.io/controller" + ControllerKey = AnnotationKeyPrefix + "controller" // The annotation used for defining the desired hostname - HostnameKey = "external-dns.alpha.kubernetes.io/hostname" + HostnameKey = AnnotationKeyPrefix + "hostname" // The annotation used for specifying whether the public or private interface address is used - AccessKey = "external-dns.alpha.kubernetes.io/access" + AccessKey = AnnotationKeyPrefix + "access" // The annotation used for specifying the type of endpoints to use for headless services - EndpointsTypeKey = "external-dns.alpha.kubernetes.io/endpoints-type" + EndpointsTypeKey = AnnotationKeyPrefix + "endpoints-type" // The annotation used to determine the source of hostnames for ingresses. This is an optional field - all // available hostname sources are used if not specified. - IngressHostnameSourceKey = "external-dns.alpha.kubernetes.io/ingress-hostname-source" + IngressHostnameSourceKey = AnnotationKeyPrefix + "ingress-hostname-source" // The value of the controller annotation so that we feel responsible ControllerValue = "dns-controller" // The annotation used for defining the desired hostname - InternalHostnameKey = "external-dns.alpha.kubernetes.io/internal-hostname" + InternalHostnameKey = AnnotationKeyPrefix + "internal-hostname" )