Skip to content

Commit b93c30e

Browse files
committed
lint: use constant for TXT record type
1 parent a418182 commit b93c30e

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

internal/stackitprovider/helper.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func getStackitRecordSetPayload(change *endpoint.Endpoint) stackitdnsclient.Crea
7373
for i := range change.Targets {
7474
content := change.Targets[i]
7575

76-
if change.RecordType == "TXT" {
76+
if change.RecordType == txtRecord {
7777
content = formatTXTContent(content)
7878
}
7979

@@ -96,7 +96,7 @@ func getStackitPartialUpdateRecordSetPayload(change *endpoint.Endpoint) stackitd
9696
for i := range change.Targets {
9797
content := change.Targets[i]
9898

99-
if change.RecordType == "TXT" {
99+
if change.RecordType == txtRecord {
100100
content = formatTXTContent(content)
101101
}
102102

@@ -139,7 +139,7 @@ func safeTTLToInt32(ttl endpoint.TTL) *int32 {
139139
return &v
140140
}
141141

142-
// formatTXTContent splits long TXT records into 255-character chunks separated by spaces
142+
// formatTXTContent splits long TXT records into 255-character chunks separated by spaces.
143143
func formatTXTContent(content string) string {
144144
cleanContent := strings.Trim(content, "\"")
145145

@@ -159,12 +159,13 @@ func formatTXTContent(content string) string {
159159
return strings.Join(chunks, " ")
160160
}
161161

162-
// unformatTXTContent reverses the DNS chunking and quoting process
162+
// unformatTXTContent reverses the DNS chunking and quoting process.
163163
func unformatTXTContent(content string) string {
164164
if !strings.HasPrefix(content, "\"") || !strings.HasSuffix(content, "\"") {
165165
return content
166166
}
167167

168168
trimmed := content[1 : len(content)-1]
169+
169170
return strings.ReplaceAll(trimmed, `" "`, "")
170171
}

internal/stackitprovider/records.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"sigs.k8s.io/external-dns/provider"
99
)
1010

11+
const txtRecord = "TXT"
12+
1113
// Records returns resource records.
1214
func (d *StackitDNSProvider) Records(ctx context.Context) ([]*endpoint.Endpoint, error) {
1315
zones, err := d.zoneFetcherClient.zones(ctx)
@@ -115,7 +117,7 @@ func endpointsFromRecords(name, recordType string, ttl endpoint.TTL, records []s
115117
rec := &records[i]
116118

117119
content := rec.Content
118-
if recordType == "TXT" {
120+
if recordType == txtRecord {
119121
content = unformatTXTContent(content)
120122
}
121123

0 commit comments

Comments
 (0)