forked from TrueCloudLab/lego
providers/azure: Refactor to work with Azure SDK version 14.0.0 (#490)
This commit is contained in:
parent
06a8e7c475
commit
4e330710a7
1 changed files with 9 additions and 4 deletions
|
@ -4,11 +4,12 @@
|
||||||
package azure
|
package azure
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Azure/azure-sdk-for-go/arm/dns"
|
"github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2017-09-01/dns"
|
||||||
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -26,6 +27,8 @@ type DNSProvider struct {
|
||||||
subscriptionId string
|
subscriptionId string
|
||||||
tenantId string
|
tenantId string
|
||||||
resourceGroup string
|
resourceGroup string
|
||||||
|
|
||||||
|
context context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDNSProvider returns a DNSProvider instance configured for azure.
|
// NewDNSProvider returns a DNSProvider instance configured for azure.
|
||||||
|
@ -53,6 +56,8 @@ func NewDNSProviderCredentials(clientId, clientSecret, subscriptionId, tenantId,
|
||||||
subscriptionId: subscriptionId,
|
subscriptionId: subscriptionId,
|
||||||
tenantId: tenantId,
|
tenantId: tenantId,
|
||||||
resourceGroup: resourceGroup,
|
resourceGroup: resourceGroup,
|
||||||
|
// TODO: A timeout can be added here for cancellation purposes.
|
||||||
|
context: context.Background(),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +87,7 @@ func (c *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
TxtRecords: &[]dns.TxtRecord{dns.TxtRecord{Value: &[]string{value}}},
|
TxtRecords: &[]dns.TxtRecord{dns.TxtRecord{Value: &[]string{value}}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
_, err = rsc.CreateOrUpdate(c.resourceGroup, zone, relative, dns.TXT, rec, "", "")
|
_, err = rsc.CreateOrUpdate(c.context, c.resourceGroup, zone, relative, dns.TXT, rec, "", "")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -109,7 +114,7 @@ func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
rsc := dns.NewRecordSetsClient(c.subscriptionId)
|
rsc := dns.NewRecordSetsClient(c.subscriptionId)
|
||||||
spt, err := c.newServicePrincipalTokenFromCredentials(azure.PublicCloud.ResourceManagerEndpoint)
|
spt, err := c.newServicePrincipalTokenFromCredentials(azure.PublicCloud.ResourceManagerEndpoint)
|
||||||
rsc.Authorizer = autorest.NewBearerAuthorizer(spt)
|
rsc.Authorizer = autorest.NewBearerAuthorizer(spt)
|
||||||
_, err = rsc.Delete(c.resourceGroup, zone, relative, dns.TXT, "")
|
_, err = rsc.Delete(c.context, c.resourceGroup, zone, relative, dns.TXT, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -130,7 +135,7 @@ func (c *DNSProvider) getHostedZoneID(fqdn string) (string, error) {
|
||||||
dc := dns.NewZonesClient(c.subscriptionId)
|
dc := dns.NewZonesClient(c.subscriptionId)
|
||||||
dc.Authorizer = autorest.NewBearerAuthorizer(spt)
|
dc.Authorizer = autorest.NewBearerAuthorizer(spt)
|
||||||
|
|
||||||
zone, err := dc.Get(c.resourceGroup, acme.UnFqdn(authZone))
|
zone, err := dc.Get(c.context, c.resourceGroup, acme.UnFqdn(authZone))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|
Loading…
Reference in a new issue