6 Commits

Author SHA1 Message Date
b62f1cf632 Bump version to v0.4.3
All checks were successful
Release workflow / Check version (push) Successful in 5s
Release workflow / Publish Helm chart (push) Successful in 32s
Release workflow / Publish Docker image (push) Successful in 2m24s
2023-10-17 14:40:27 -04:00
cfc6360ffc Revert secret decoding "fixes"
Apparently the data from the secret is already decoded?
2023-10-17 14:39:57 -04:00
9b1fde11a2 Bump version to v0.4.2
All checks were successful
Release workflow / Check version (push) Successful in 5s
Release workflow / Publish Helm chart (push) Successful in 33s
Release workflow / Publish Docker image (push) Successful in 2m22s
2023-10-17 14:23:37 -04:00
8c1403a87b Add release script 2023-10-17 14:23:37 -04:00
9d4d1a1d03 Add env var for debugging http calls 2023-10-17 13:44:42 -04:00
cdaa33a539 Properly initialize base64 decoding buffer 2023-10-17 13:41:48 -04:00
3 changed files with 44 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
apiVersion: v2
description: A Helm chart for cert-manager-webhook-gandi
name: cert-manager-webhook-gandi
version: v0.4.1
version: v0.4.3

23
main.go
View File

@@ -2,7 +2,6 @@ package main
import (
"context"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
@@ -29,7 +28,10 @@ const (
GandiMinTtl = 300 // Gandi reports an error for values < this value
)
var GroupName = os.Getenv("GROUP_NAME")
var (
DebugHTTP = os.Getenv("DEBUG_HTTP")
GroupName = os.Getenv("GROUP_NAME")
)
func main() {
if GroupName == "" {
@@ -203,33 +205,28 @@ func (c *gandiDNSProviderSolver) newClient(ch *v1alpha1.ChallengeRequest) (*live
}
return gandi.NewLiveDNSClient(config.Config{
APIKey: *apiKey,
APIKey: apiKey,
Timeout: time.Second * 30,
Debug: DebugHTTP != "",
}), nil
}
// Get Gandi API key from Kubernetes secret.
func (c *gandiDNSProviderSolver) getApiKey(cfg *gandiDNSProviderConfig, namespace string) (*string, error) {
func (c *gandiDNSProviderSolver) getApiKey(cfg *gandiDNSProviderConfig, namespace string) (string, error) {
secretName := cfg.APIKeySecretRef.LocalObjectReference.Name
klog.V(6).Infof("try to load secret `%s` with key `%s`", secretName, cfg.APIKeySecretRef.Key)
sec, err := c.client.CoreV1().Secrets(namespace).Get(context.Background(), secretName, metav1.GetOptions{})
if err != nil {
return nil, fmt.Errorf("unable to get secret `%s`; %v", secretName, err)
return "", fmt.Errorf("unable to get secret `%s`; %v", secretName, err)
}
secBytes, ok := sec.Data[cfg.APIKeySecretRef.Key]
if !ok {
return nil, fmt.Errorf("key %q not found in secret \"%s/%s\"", cfg.APIKeySecretRef.Key,
return "", fmt.Errorf("key %q not found in secret \"%s/%s\"", cfg.APIKeySecretRef.Key,
cfg.APIKeySecretRef.LocalObjectReference.Name, namespace)
}
var decoded []byte
_, err = base64.RawStdEncoding.Decode(decoded, secBytes)
if err != nil {
return nil, fmt.Errorf("failed to decode api key secret: %w", err)
}
apiKey := string(decoded)
return &apiKey, nil
return string(secBytes), nil
}

33
scripts/release.sh Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/sh -eux
cd "$(dirname "$0")"
version="$(yq '.version' ../deploy/cert-manager-webhook-gandi/Chart.yaml)"
version="${version#v}"
major="$(echo "$version" | cut -d'.' -f1)"
minor="$(echo "$version" | cut -d'.' -f2)"
patch="$(echo "$version" | cut -d'.' -f3)"
case "${1:-""}" in
major)
major=$((major + 1))
minor=0
patch=0
;;
minor)
minor=$((minor + 1))
patch=0
;;
patch)
patch=$((patch + 1))
;;
*)
echo "Unknown release type"
exit 1
;;
esac
version="$major.$minor.$patch"
yq -i ".version |= \"v$version\"" ../deploy/cert-manager-webhook-gandi/Chart.yaml
git add ../deploy/
git commit -m "Bump version to v$version"
git tag -a "v$version"