Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Azure DNS): add NS record support #4846

Merged
merged 1 commit into from
Dec 15, 2024
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
23 changes: 23 additions & 0 deletions provider/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,19 @@ func (p *AzureProvider) newRecordSet(endpoint *endpoint.Endpoint) (dns.RecordSet
MxRecords: mxRecords,
},
}, nil
case dns.RecordTypeNS:
nsRecords := make([]*dns.NsRecord, len(endpoint.Targets))
for i, target := range endpoint.Targets {
nsRecords[i] = &dns.NsRecord{
Nsdname: to.Ptr(target),
}
}
return dns.RecordSet{
Properties: &dns.RecordSetProperties{
TTL: to.Ptr(ttl),
NsRecords: nsRecords,
},
}, nil
case dns.RecordTypeTXT:
return dns.RecordSet{
Properties: &dns.RecordSetProperties{
Expand Down Expand Up @@ -460,6 +473,16 @@ func extractAzureTargets(recordSet *dns.RecordSet) []string {
return targets
}

// Check for NS records
nsRecords := properties.NsRecords
if len(nsRecords) > 0 && (nsRecords)[0].Nsdname != nil {
targets := make([]string, len(nsRecords))
for i, nsRecord := range nsRecords {
targets[i] = *nsRecord.Nsdname
}
return targets
}

// Check for TXT records
txtRecords := properties.TxtRecords
if len(txtRecords) > 0 && (txtRecords)[0].Value != nil {
Expand Down
8 changes: 4 additions & 4 deletions provider/azure/azure_privatedns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,9 @@ func TestAzurePrivateDNSApplyChanges(t *testing.T) {
}

func TestAzurePrivateDNSApplyChangesDryRun(t *testing.T) {
recordsClient := mockRecordSetsClient{}
recordsClient := mockPrivateRecordSetsClient{}

testAzureApplyChangesInternal(t, true, &recordsClient)
testAzurePrivateDNSApplyChangesInternal(t, true, &recordsClient)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While implementing my change I noticed the private zone tests were using an AzureProvider instead of a AzurePrivateDNSProvider


validateAzureEndpoints(t, recordsClient.deletedEndpoints, []*endpoint.Endpoint{})

Expand Down Expand Up @@ -471,9 +471,9 @@ func TestAzurePrivateDNSNameFilter(t *testing.T) {
}

func TestAzurePrivateDNSApplyChangesZoneName(t *testing.T) {
recordsClient := mockRecordSetsClient{}
recordsClient := mockPrivateRecordSetsClient{}

testAzureApplyChangesInternalZoneName(t, false, &recordsClient)
testAzurePrivateDNSApplyChangesInternalZoneName(t, false, &recordsClient)

validateAzureEndpoints(t, recordsClient.deletedEndpoints, []*endpoint.Endpoint{
endpoint.NewEndpoint("deleted.foo.example.com", endpoint.RecordTypeA, ""),
Expand Down
Loading
Loading