fix(google): ensure trailing dot for SRV records

This commit is contained in:
Dieter Bocklandt 2023-11-14 17:12:56 +01:00
parent 438d06f3c4
commit 6a3e97083c
No known key found for this signature in database
GPG Key ID: EEB85BE247F2D324
2 changed files with 27 additions and 0 deletions

View File

@ -467,6 +467,12 @@ func newRecord(ep *endpoint.Endpoint) *dns.ResourceRecordSet {
}
}
if ep.RecordType == endpoint.RecordTypeSRV {
for i, srvRecord := range ep.Targets {
targets[i] = provider.EnsureTrailingDot(srvRecord)
}
}
// no annotation results in a Ttl of 0, default to 300 for backwards-compatibility
var ttl int64 = googleRecordTTL
if ep.RecordTTL.IsConfigured() {

View File

@ -383,6 +383,27 @@ func testCRDSourceEndpoints(t *testing.T) {
expectEndpoints: true,
expectError: false,
},
{
title: "Create SRV 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: "_svc._tcp.example.org",
Targets: endpoint.Targets{"0 0 80 abc.example.org", "0 0 80 def.example.org"},
RecordType: endpoint.RecordTypeSRV,
RecordTTL: 180,
},
},
expectEndpoints: true,
expectError: false,
},
} {
ti := ti
t.Run(ti.title, func(t *testing.T) {