From 4e330710a7dd17d7112fdd0eab7bad973e3955cd Mon Sep 17 00:00:00 2001 From: Aaryaman Vasishta Date: Thu, 15 Feb 2018 05:28:02 +0900 Subject: [PATCH] providers/azure: Refactor to work with Azure SDK version 14.0.0 (#490) --- providers/dns/azure/azure.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/providers/dns/azure/azure.go b/providers/dns/azure/azure.go index 6a30b318..cc15ca7e 100644 --- a/providers/dns/azure/azure.go +++ b/providers/dns/azure/azure.go @@ -4,11 +4,12 @@ package azure import ( + "context" "fmt" "os" "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" @@ -26,6 +27,8 @@ type DNSProvider struct { subscriptionId string tenantId string resourceGroup string + + context context.Context } // NewDNSProvider returns a DNSProvider instance configured for azure. @@ -53,6 +56,8 @@ func NewDNSProviderCredentials(clientId, clientSecret, subscriptionId, tenantId, subscriptionId: subscriptionId, tenantId: tenantId, resourceGroup: resourceGroup, + // TODO: A timeout can be added here for cancellation purposes. + context: context.Background(), }, nil } @@ -82,7 +87,7 @@ func (c *DNSProvider) Present(domain, token, keyAuth string) error { 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 { return err @@ -109,7 +114,7 @@ func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error { rsc := dns.NewRecordSetsClient(c.subscriptionId) spt, err := c.newServicePrincipalTokenFromCredentials(azure.PublicCloud.ResourceManagerEndpoint) 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 { return err } @@ -130,7 +135,7 @@ func (c *DNSProvider) getHostedZoneID(fqdn string) (string, error) { dc := dns.NewZonesClient(c.subscriptionId) 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 { return "", err