Skip to content

Commit

Permalink
move zone name override into group getHostedZoneID
Browse files Browse the repository at this point in the history
  • Loading branch information
sa-ChristianAnton committed Jul 16, 2021
1 parent dbb8058 commit dee5ac7
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions providers/dns/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,9 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
ctx := context.Background()
fqdn, value := dns01.GetRecord(domain, keyAuth)

var zone string
if env.GetOrFile(EnvZoneName) != "" {
zone = env.GetOrFile(EnvZoneName)
} else {
var err error
zone, err = d.getHostedZoneID(ctx, fqdn)
if err != nil {
return fmt.Errorf("azure: %w", err)
}
zone, err := d.getHostedZoneID(ctx, fqdn)
if err != nil {
return fmt.Errorf("azure: %w", err)
}

rsc := dns.NewRecordSetsClientWithBaseURI(d.config.ResourceManagerEndpoint, d.config.SubscriptionID)
Expand Down Expand Up @@ -232,15 +226,9 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
fqdn, _ := dns01.GetRecord(domain, keyAuth)


var zone string
var err error
if env.GetOrFile(EnvZoneName) != "" {
zone = env.GetOrFile(EnvZoneName)
} else {
zone, err = d.getHostedZoneID(ctx, fqdn)
if err != nil {
return fmt.Errorf("azure: %w", err)
}
zone, err := d.getHostedZoneID(ctx, fqdn)
if err != nil {
return fmt.Errorf("azure: %w", err)
}

relative := toRelativeRecord(fqdn, dns01.ToFqdn(zone))
Expand All @@ -256,6 +244,10 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {

// Checks that azure has a zone for this domain name.
func (d *DNSProvider) getHostedZoneID(ctx context.Context, fqdn string) (string, error) {
if env.GetOrFile(EnvZoneName) != "" {
return env.GetOrFile(EnvZoneName), nil
}

authZone, err := dns01.FindZoneByFqdn(fqdn)
if err != nil {
return "", err
Expand Down

0 comments on commit dee5ac7

Please sign in to comment.