Skip to content

Commit 7fb5299

Browse files
committed
RFC2136: return string from findMsgZone
1 parent 714078d commit 7fb5299

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

provider/rfc2136/rfc2136.go

+12-10
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,9 @@ func (r rfc2136Provider) ApplyChanges(ctx context.Context, changes *plan.Changes
263263
continue
264264
}
265265

266-
findMsgZone(ep, m, &r)
266+
zone := findMsgZone(ep, m, r)
267+
r.krb5Realm = strings.ToUpper(zone)
268+
m.SetUpdate(zone)
267269

268270
r.AddRecord(m, ep)
269271
}
@@ -290,7 +292,9 @@ func (r rfc2136Provider) ApplyChanges(ctx context.Context, changes *plan.Changes
290292
continue
291293
}
292294

293-
findMsgZone(ep, m, &r)
295+
zone := findMsgZone(ep, m, r)
296+
r.krb5Realm = strings.ToUpper(zone)
297+
m.SetUpdate(zone)
294298

295299
r.UpdateRecord(m, changes.UpdateOld[i], ep)
296300
}
@@ -317,7 +321,9 @@ func (r rfc2136Provider) ApplyChanges(ctx context.Context, changes *plan.Changes
317321
continue
318322
}
319323

320-
findMsgZone(ep, m, &r)
324+
zone := findMsgZone(ep, m, r)
325+
r.krb5Realm = strings.ToUpper(zone)
326+
m.SetUpdate(zone)
321327

322328
r.RemoveRecord(m, ep)
323329
}
@@ -451,17 +457,13 @@ func chunkBy(slice []*endpoint.Endpoint, chunkSize int) [][]*endpoint.Endpoint {
451457
return chunks
452458
}
453459

454-
func findMsgZone(ep *endpoint.Endpoint, m *dns.Msg, r *rfc2136Provider) {
460+
func findMsgZone(ep *endpoint.Endpoint, m *dns.Msg, r rfc2136Provider) string {
455461
for _, zone := range r.zoneNames {
456462
if strings.HasSuffix(ep.DNSName, zone) {
457-
r.krb5Realm = strings.ToUpper(dns.Fqdn(zone))
458-
m.SetUpdate(dns.Fqdn(zone))
459-
460-
return
463+
return dns.Fqdn(zone)
461464
}
462465
}
463466

464467
log.Warnf("No available zone found for %s, set it to 'root'", ep.DNSName)
465-
r.krb5Realm = dns.Fqdn(".")
466-
m.SetUpdate(dns.Fqdn("."))
468+
return dns.Fqdn(".")
467469
}

0 commit comments

Comments
 (0)