mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-06 17:46:57 +02:00
commit
4dc15d917e
@ -44,6 +44,8 @@ const (
|
|||||||
RecordTypePTR = "PTR"
|
RecordTypePTR = "PTR"
|
||||||
// RecordTypeMX is a RecordType enum value
|
// RecordTypeMX is a RecordType enum value
|
||||||
RecordTypeMX = "MX"
|
RecordTypeMX = "MX"
|
||||||
|
// RecordTypeNAPTR is a RecordType enum value
|
||||||
|
RecordTypeNAPTR = "NAPTR"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TTL is a structure defining the TTL of a DNS record
|
// TTL is a structure defining the TTL of a DNS record
|
||||||
|
@ -190,7 +190,11 @@ func (cs *crdSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, error
|
|||||||
|
|
||||||
illegalTarget := false
|
illegalTarget := false
|
||||||
for _, target := range ep.Targets {
|
for _, target := range ep.Targets {
|
||||||
if strings.HasSuffix(target, ".") {
|
if ep.RecordType != "NAPTR" && strings.HasSuffix(target, ".") {
|
||||||
|
illegalTarget = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if ep.RecordType == "NAPTR" && !strings.HasSuffix(target, ".") {
|
||||||
illegalTarget = true
|
illegalTarget = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -404,6 +404,69 @@ func testCRDSourceEndpoints(t *testing.T) {
|
|||||||
expectEndpoints: true,
|
expectEndpoints: true,
|
||||||
expectError: false,
|
expectError: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: "Create NAPTR record",
|
||||||
|
registeredAPIVersion: "test.k8s.io/v1alpha1",
|
||||||
|
apiVersion: "test.k8s.io/v1alpha1",
|
||||||
|
registeredKind: "DNSEndpoint",
|
||||||
|
kind: "DNSEndpoint",
|
||||||
|
namespace: "foo",
|
||||||
|
registeredNamespace: "foo",
|
||||||
|
labels: map[string]string{"test": "that"},
|
||||||
|
labelFilter: "test=that",
|
||||||
|
endpoints: []*endpoint.Endpoint{
|
||||||
|
{
|
||||||
|
DNSName: "example.org",
|
||||||
|
Targets: endpoint.Targets{`100 10 "S" "SIP+D2U" "!^.*$!sip:customer-service@example.org!" _sip._udp.example.org.`, `102 10 "S" "SIP+D2T" "!^.*$!sip:customer-service@example.org!" _sip._tcp.example.org.`},
|
||||||
|
RecordType: endpoint.RecordTypeNAPTR,
|
||||||
|
RecordTTL: 180,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectEndpoints: true,
|
||||||
|
expectError: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "illegal target CNAME",
|
||||||
|
registeredAPIVersion: "test.k8s.io/v1alpha1",
|
||||||
|
apiVersion: "test.k8s.io/v1alpha1",
|
||||||
|
registeredKind: "DNSEndpoint",
|
||||||
|
kind: "DNSEndpoint",
|
||||||
|
namespace: "foo",
|
||||||
|
registeredNamespace: "foo",
|
||||||
|
labels: map[string]string{"test": "that"},
|
||||||
|
labelFilter: "test=that",
|
||||||
|
endpoints: []*endpoint.Endpoint{
|
||||||
|
{
|
||||||
|
DNSName: "example.org",
|
||||||
|
Targets: endpoint.Targets{"foo.example.org."},
|
||||||
|
RecordType: endpoint.RecordTypeCNAME,
|
||||||
|
RecordTTL: 180,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectEndpoints: false,
|
||||||
|
expectError: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "illegal target NAPTR",
|
||||||
|
registeredAPIVersion: "test.k8s.io/v1alpha1",
|
||||||
|
apiVersion: "test.k8s.io/v1alpha1",
|
||||||
|
registeredKind: "DNSEndpoint",
|
||||||
|
kind: "DNSEndpoint",
|
||||||
|
namespace: "foo",
|
||||||
|
registeredNamespace: "foo",
|
||||||
|
labels: map[string]string{"test": "that"},
|
||||||
|
labelFilter: "test=that",
|
||||||
|
endpoints: []*endpoint.Endpoint{
|
||||||
|
{
|
||||||
|
DNSName: "example.org",
|
||||||
|
Targets: endpoint.Targets{`100 10 "S" "SIP+D2U" "!^.*$!sip:customer-service@example.org!" _sip._udp.example.org`, `102 10 "S" "SIP+D2T" "!^.*$!sip:customer-service@example.org!" _sip._tcp.example.org`},
|
||||||
|
RecordType: endpoint.RecordTypeNAPTR,
|
||||||
|
RecordTTL: 180,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectEndpoints: false,
|
||||||
|
expectError: false,
|
||||||
|
},
|
||||||
} {
|
} {
|
||||||
ti := ti
|
ti := ti
|
||||||
t.Run(ti.title, func(t *testing.T) {
|
t.Run(ti.title, func(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user