From 90054dc45d00fe324e5aa772bcc59c506ba1e24d Mon Sep 17 00:00:00 2001 From: Mohammad Yosefpor <47300215+m-yosefpor@users.noreply.github.com> Date: Sat, 24 Jul 2021 23:17:41 +0430 Subject: [PATCH] Update deployment api group to v1 (#7) And better error handling --- charts/alidns-webhook/templates/deployment.yaml | 2 +- main.go | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/charts/alidns-webhook/templates/deployment.yaml b/charts/alidns-webhook/templates/deployment.yaml index 9272ae1..2a91662 100644 --- a/charts/alidns-webhook/templates/deployment.yaml +++ b/charts/alidns-webhook/templates/deployment.yaml @@ -1,4 +1,4 @@ -apiVersion: apps/v1beta2 +apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "alidns-webhook.fullname" . }} diff --git a/main.go b/main.go index b6ea8ea..2f63364 100644 --- a/main.go +++ b/main.go @@ -80,7 +80,7 @@ type aliDNSProviderConfig struct { AccessToken cmmetav1.SecretKeySelector `json:"accessTokenSecretRef"` SecretToken cmmetav1.SecretKeySelector `json:"secretKeySecretRef"` - Regionid string `json:"regionId"` + Regionid string `json:"regionId"` } // Name is used as the name for this DNS solver when referencing it on the ACME @@ -108,6 +108,9 @@ func (c *aliDNSProviderSolver) Present(ch *v1alpha1.ChallengeRequest) error { fmt.Printf("Decoded configuration: %v\n", cfg) accessToken, err := c.loadSecretData(cfg.AccessToken, ch.ResourceNamespace) + if err != nil { + return err + } secretKey, err := c.loadSecretData(cfg.SecretToken, ch.ResourceNamespace) if err != nil { return err @@ -117,6 +120,9 @@ func (c *aliDNSProviderSolver) Present(ch *v1alpha1.ChallengeRequest) error { credential := credentials.NewAccessKeyCredential(string(accessToken), string(secretKey)) client, err := alidns.NewClientWithOptions(cfg.Regionid, conf, credential) + if err != nil { + return err + } c.aliDNSClient = client _, zoneName, err := c.getHostedZone(ch.ResolvedZone)