Merge pull request #2146 from gottwald/clouddns-cleanup

Cleanup clouddns package
This commit is contained in:
jetstack-bot 2019-10-15 16:04:04 +01:00 committed by GitHub
commit f57ee108c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 6 deletions

View File

@ -9,8 +9,8 @@ go_library(
"//pkg/issuer/acme/dns/util:go_default_library",
"@io_k8s_klog//:go_default_library",
"@org_golang_google_api//dns/v1:go_default_library",
"@org_golang_google_api//option:go_default_library",
"@org_golang_x_net//context:go_default_library",
"@org_golang_x_oauth2//:go_default_library",
"@org_golang_x_oauth2//google:go_default_library",
],
)

View File

@ -17,9 +17,9 @@ import (
"time"
"golang.org/x/net/context"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
"google.golang.org/api/dns/v1"
"google.golang.org/api/option"
"github.com/jetstack/cert-manager/pkg/issuer/acme/dns/util"
"k8s.io/klog"
@ -71,11 +71,12 @@ func NewDNSProviderCredentials(project string, dns01Nameservers []string) (*DNSP
return nil, fmt.Errorf("Google Cloud project name missing")
}
client, err := google.DefaultClient(context.Background(), dns.NdevClouddnsReadwriteScope)
ctx := context.Background()
client, err := google.DefaultClient(ctx, dns.NdevClouddnsReadwriteScope)
if err != nil {
return nil, fmt.Errorf("Unable to get Google Cloud client: %v", err)
}
svc, err := dns.New(client)
svc, err := dns.NewService(ctx, option.WithHTTPClient(client))
if err != nil {
return nil, fmt.Errorf("Unable to create Google Cloud DNS service: %v", err)
}
@ -117,9 +118,11 @@ func NewDNSProviderServiceAccountBytes(project string, saBytes []byte, dns01Name
if err != nil {
return nil, fmt.Errorf("Unable to acquire config: %v", err)
}
client := conf.Client(oauth2.NoContext)
svc, err := dns.New(client)
ctx := context.Background()
client := conf.Client(ctx)
svc, err := dns.NewService(ctx, option.WithHTTPClient(client))
if err != nil {
return nil, fmt.Errorf("Unable to create Google Cloud DNS service: %v", err)
}

View File

@ -89,6 +89,7 @@ func TestLiveGoogleCloudPresentMultiple(t *testing.T) {
// Check that we're able to create multiple entries
err = provider.Present(gcloudDomain, "_acme-challenge."+gcloudDomain+".", "123d==")
assert.NoError(t, err)
err = provider.Present(gcloudDomain, "_acme-challenge."+gcloudDomain+".", "1123d==")
assert.NoError(t, err)
}