Skip to content

Commit

Permalink
following review from @Raffo
Browse files Browse the repository at this point in the history
  • Loading branch information
mloiseleur committed Dec 7, 2023
1 parent d98a28e commit 4e6edaa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion provider/ns1/ns1.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (p *NS1Provider) Records(ctx context.Context) ([]*endpoint.Endpoint, error)

// ns1BuildRecord returns a dns.Record for a change set
func (p *NS1Provider) ns1BuildRecord(zoneName string, change *ns1Change) *dns.Record {
record := dns.NewRecord(zoneName, change.Endpoint.DNSName, change.Endpoint.RecordType, nil, nil)
record := dns.NewRecord(zoneName, change.Endpoint.DNSName, change.Endpoint.RecordType, map[string]string{}, []string{})
for _, v := range change.Endpoint.Targets {
record.AddAnswer(dns.NewAnswer(strings.Split(v, " ")))
}
Expand Down
10 changes: 5 additions & 5 deletions provider/rfc2136/rfc2136_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func newStub() *rfc2136Stub {

func (r *rfc2136Stub) SendMessage(msg *dns.Msg) error {
log.Info(msg.String())
lines := extractAuthoritySectionFromMessage(msg)
lines := extractUpdateSectionFromMessage(msg)
for _, line := range lines {
// break at first empty line
if len(strings.TrimSpace(line)) == 0 {
Expand Down Expand Up @@ -98,10 +98,10 @@ func createRfc2136StubProvider(stub *rfc2136Stub) (provider.Provider, error) {
return NewRfc2136Provider("", 0, nil, false, "key", "secret", "hmac-sha512", true, endpoint.DomainFilter{}, false, 300*time.Second, false, "", "", "", 50, stub)
}

func extractAuthoritySectionFromMessage(msg fmt.Stringer) []string {
func extractUpdateSectionFromMessage(msg fmt.Stringer) []string {
const searchPattern = "UPDATE SECTION:"
authoritySectionOffset := strings.Index(msg.String(), searchPattern)
return strings.Split(strings.TrimSpace(msg.String()[authoritySectionOffset+len(searchPattern):]), "\n")
updateSectionOffset := strings.Index(msg.String(), searchPattern)
return strings.Split(strings.TrimSpace(msg.String()[updateSectionOffset+len(searchPattern):]), "\n")
}

// TestRfc2136GetRecordsMultipleTargets simulates a single record with multiple targets.
Expand Down Expand Up @@ -241,7 +241,7 @@ func TestRfc2136ApplyChangesWithDifferentTTLs(t *testing.T) {
err = provider.ApplyChanges(context.Background(), p)
assert.NoError(t, err)

createRecords := extractAuthoritySectionFromMessage(stub.createMsgs[0])
createRecords := extractUpdateSectionFromMessage(stub.createMsgs[0])
assert.Equal(t, 3, len(createRecords))
assert.True(t, strings.Contains(createRecords[0], "v1.foo.com"))
assert.True(t, strings.Contains(createRecords[0], "2.1.1.1"))
Expand Down

0 comments on commit 4e6edaa

Please sign in to comment.