Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions provider/cloudflare/cloudflare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@ import (
"sigs.k8s.io/external-dns/source/annotations"
)

// TestMain initializes annotation keys before running tests.
// This is needed because init() was removed from annotations package.
func TestMain(m *testing.M) {
annotations.SetAnnotationPrefix("external-dns.alpha.kubernetes.io/")
m.Run()
}

// newCloudflareError creates a cloudflare.Error suitable for testing.
// The v5 SDK's Error type panics when .Error() is called with nil Request/Response fields,
// so this helper initializes them properly.
Expand Down
44 changes: 22 additions & 22 deletions source/annotations/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,41 @@ var (
AnnotationKeyPrefix = DefaultAnnotationPrefix

// CloudflareProxiedKey The annotation used for determining if traffic will go through Cloudflare
CloudflareProxiedKey string
CloudflareCustomHostnameKey string
CloudflareRegionKey string
CloudflareRecordCommentKey string
CloudflareTagsKey string
CloudflareProxiedKey = AnnotationKeyPrefix + "cloudflare-proxied"
CloudflareCustomHostnameKey = AnnotationKeyPrefix + "cloudflare-custom-hostname"
CloudflareRegionKey = AnnotationKeyPrefix + "cloudflare-region-key"
CloudflareRecordCommentKey = AnnotationKeyPrefix + "cloudflare-record-comment"
CloudflareTagsKey = AnnotationKeyPrefix + "cloudflare-tags"

AWSPrefix string
CoreDNSPrefix string
SCWPrefix string
WebhookPrefix string
CloudflarePrefix string
AWSPrefix = AnnotationKeyPrefix + "aws-"
CoreDNSPrefix = AnnotationKeyPrefix + "coredns-"
SCWPrefix = AnnotationKeyPrefix + "scw-"
WebhookPrefix = AnnotationKeyPrefix + "webhook-"
CloudflarePrefix = AnnotationKeyPrefix + "cloudflare-"

TtlKey string
SetIdentifierKey string
AliasKey string
TargetKey string
TtlKey = AnnotationKeyPrefix + "ttl"
SetIdentifierKey = AnnotationKeyPrefix + "set-identifier"
AliasKey = AnnotationKeyPrefix + "alias"
TargetKey = AnnotationKeyPrefix + "target"
// ControllerKey The annotation used for figuring out which controller is responsible
ControllerKey string
ControllerKey = AnnotationKeyPrefix + "controller"
// HostnameKey The annotation used for defining the desired hostname
HostnameKey string
HostnameKey = AnnotationKeyPrefix + "hostname"
// AccessKey The annotation used for specifying whether the public or private interface address is used
AccessKey string
AccessKey = AnnotationKeyPrefix + "access"
// EndpointsTypeKey The annotation used for specifying the type of endpoints to use for headless services
EndpointsTypeKey string
EndpointsTypeKey = AnnotationKeyPrefix + "endpoints-type"
// Ingress the annotation used to determine if the gateway is implemented by an Ingress object
Ingress string
Ingress = AnnotationKeyPrefix + "ingress"
// IngressHostnameSourceKey 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 string
IngressHostnameSourceKey = AnnotationKeyPrefix + "ingress-hostname-source"
// ControllerValue The value of the controller annotation so that we feel responsible
ControllerValue = "dns-controller"
// InternalHostnameKey The annotation used for defining the desired hostname
InternalHostnameKey string
InternalHostnameKey = AnnotationKeyPrefix + "internal-hostname"
// The annotation used for defining the desired hostname source for gateways
GatewayHostnameSourceKey string
GatewayHostnameSourceKey = AnnotationKeyPrefix + "gateway-hostname-source"
)

// SetAnnotationPrefix sets a custom annotation prefix and rebuilds all annotation keys.
Expand Down
26 changes: 12 additions & 14 deletions source/annotations/annotations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ import (
)

func TestSetAnnotationPrefix(t *testing.T) {
// Save original values
originalPrefix := AnnotationKeyPrefix
defer SetAnnotationPrefix(originalPrefix)
t.Cleanup(func() { SetAnnotationPrefix(DefaultAnnotationPrefix) })

// Test custom prefix
customPrefix := "custom.io/"
Expand Down Expand Up @@ -59,17 +57,17 @@ func TestSetAnnotationPrefix(t *testing.T) {
}

func TestDefaultAnnotationPrefix(t *testing.T) {
assert.Equal(t, "external-dns.alpha.kubernetes.io/", AnnotationKeyPrefix)
assert.Equal(t, "external-dns.alpha.kubernetes.io/hostname", HostnameKey)
assert.Equal(t, "external-dns.alpha.kubernetes.io/internal-hostname", InternalHostnameKey)
assert.Equal(t, "external-dns.alpha.kubernetes.io/ttl", TtlKey)
assert.Equal(t, "external-dns.alpha.kubernetes.io/controller", ControllerKey)
t.Cleanup(func() { SetAnnotationPrefix(DefaultAnnotationPrefix) })
SetAnnotationPrefix(DefaultAnnotationPrefix)
assert.Equal(t, DefaultAnnotationPrefix, AnnotationKeyPrefix)
assert.Equal(t, DefaultAnnotationPrefix+"hostname", HostnameKey)
assert.Equal(t, DefaultAnnotationPrefix+"internal-hostname", InternalHostnameKey)
assert.Equal(t, DefaultAnnotationPrefix+"ttl", TtlKey)
assert.Equal(t, DefaultAnnotationPrefix+"controller", ControllerKey)
}

func TestSetAnnotationPrefixMultipleTimes(t *testing.T) {
// Save original values
originalPrefix := AnnotationKeyPrefix
defer SetAnnotationPrefix(originalPrefix)
t.Cleanup(func() { SetAnnotationPrefix(DefaultAnnotationPrefix) })

// Set first custom prefix
SetAnnotationPrefix("first.io/")
Expand All @@ -82,7 +80,7 @@ func TestSetAnnotationPrefixMultipleTimes(t *testing.T) {
assert.Equal(t, "second.io/hostname", HostnameKey)

// Restore to default
SetAnnotationPrefix("external-dns.alpha.kubernetes.io/")
assert.Equal(t, "external-dns.alpha.kubernetes.io/", AnnotationKeyPrefix)
assert.Equal(t, "external-dns.alpha.kubernetes.io/hostname", HostnameKey)
SetAnnotationPrefix(DefaultAnnotationPrefix)
assert.Equal(t, DefaultAnnotationPrefix, AnnotationKeyPrefix)
assert.Equal(t, DefaultAnnotationPrefix+"hostname", HostnameKey)
}
2 changes: 0 additions & 2 deletions source/annotations/processors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,6 @@ func TestInternalHostnamesFromAnnotations(t *testing.T) {
}

func TestIsControllerMismatch(t *testing.T) {
SetAnnotationPrefix(DefaultAnnotationPrefix)

tests := []struct {
name string
annotations map[string]string
Expand Down
7 changes: 0 additions & 7 deletions source/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ import (
"sigs.k8s.io/external-dns/source/informers"
)

// TestMain initializes annotation keys before running tests.
// This is needed because init() was removed from annotations package.
func TestMain(m *testing.M) {
annotations.SetAnnotationPrefix("external-dns.alpha.kubernetes.io/")
m.Run()
}

type ServiceSuite struct {
suite.Suite
sc Source
Expand Down
Loading