Skip to content

Commit

Permalink
RFC2136 Rename field zoneName to zoneNames
Browse files Browse the repository at this point in the history
  • Loading branch information
CRASH-Tech committed Oct 16, 2023
1 parent 3e59dc3 commit 98e9716
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions provider/rfc2136/rfc2136.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const (
type rfc2136Provider struct {
provider.BaseProvider
nameserver string
zoneName []string
zoneNames []string
tsigKeyName string
tsigSecret string
tsigSecretAlg string
Expand Down Expand Up @@ -82,20 +82,20 @@ type rfc2136Actions interface {
}

// NewRfc2136Provider is a factory function for OpenStack rfc2136 providers
func NewRfc2136Provider(host string, port int, zoneName []string, insecure bool, keyName string, secret string, secretAlg string, axfr bool, domainFilter endpoint.DomainFilter, dryRun bool, minTTL time.Duration, gssTsig bool, krb5Username string, krb5Password string, krb5Realm string, batchChangeSize int, actions rfc2136Actions) (provider.Provider, error) {
func NewRfc2136Provider(host string, port int, zoneNames []string, insecure bool, keyName string, secret string, secretAlg string, axfr bool, domainFilter endpoint.DomainFilter, dryRun bool, minTTL time.Duration, gssTsig bool, krb5Username string, krb5Password string, krb5Realm string, batchChangeSize int, actions rfc2136Actions) (provider.Provider, error) {
secretAlgChecked, ok := tsigAlgs[secretAlg]
if !ok && !insecure && !gssTsig {
return nil, errors.Errorf("%s is not supported TSIG algorithm", secretAlg)
}

// Sort zones
sort.Slice(zoneName, func(i, j int) bool {
return len(strings.Split(zoneName[i], ".")) > len(strings.Split(zoneName[j], "."))
sort.Slice(zoneNames, func(i, j int) bool {
return len(strings.Split(zoneNames[i], ".")) > len(strings.Split(zoneNames[j], "."))
})

r := &rfc2136Provider{
nameserver: net.JoinHostPort(host, strconv.Itoa(port)),
zoneName: zoneName,
zoneNames: zoneNames,
insecure: insecure,
gssTsig: gssTsig,
krb5Username: krb5Username,
Expand All @@ -119,7 +119,7 @@ func NewRfc2136Provider(host string, port int, zoneName []string, insecure bool,
r.tsigSecretAlg = secretAlgChecked
}

log.Infof("Configured RFC2136 with zone '%s' and nameserver '%s'", r.zoneName, r.nameserver)
log.Infof("Configured RFC2136 with zone '%s' and nameserver '%s'", r.zoneNames, r.nameserver)
return r, nil
}

Expand Down Expand Up @@ -212,7 +212,7 @@ func (r rfc2136Provider) List() ([]dns.RR, error) {
}

records := make([]dns.RR, 0)
for _, zone := range r.zoneName {
for _, zone := range r.zoneNames {
log.Debugf("Fetching records for '%s'", zone)

m := new(dns.Msg)
Expand Down Expand Up @@ -447,7 +447,7 @@ func chunkBy(slice []*endpoint.Endpoint, chunkSize int) [][]*endpoint.Endpoint {
}

func findMsgZone(ep *endpoint.Endpoint, m *dns.Msg, r *rfc2136Provider) {
for _, zone := range r.zoneName {
for _, zone := range r.zoneNames {
if strings.HasSuffix(ep.DNSName, zone) {
r.krb5Realm = strings.ToUpper(dns.Fqdn(zone))
m.SetUpdate(dns.Fqdn(zone))
Expand Down

0 comments on commit 98e9716

Please sign in to comment.