Skip to content

Commit

Permalink
fix(google): ensure trailing dot for SRV records
Browse files Browse the repository at this point in the history
  • Loading branch information
siliconsheep committed Nov 14, 2023
1 parent 438d06f commit 6a3e970
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions provider/google/google.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
21 changes: 21 additions & 0 deletions source/crd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 6a3e970

Please sign in to comment.