From 515ba49c84fe45a18251fa049b843ead0201f107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Sat, 12 Mar 2022 23:57:26 +0000 Subject: [PATCH] Try get the secretObj --- main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/main.go b/main.go index 8368df4..da78d24 100644 --- a/main.go +++ b/main.go @@ -1,11 +1,13 @@ package main import ( + "context" "encoding/json" "fmt" "os" extapi "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" @@ -94,6 +96,14 @@ func (c *customDNSProviderSolver) Present(ch *v1alpha1.ChallengeRequest) error { // TODO: do something more useful with the decoded configuration fmt.Printf("Decoded configuration %v", cfg) + secretName := cfg.SecretRef + secretObj, err := c.client.CoreV1().Secrets(ch.ResourceNamespace).Get(context.Background(), secretName, metav1.GetOptions{}) + if err != nil { + return fmt.Errorf("Unable to get secret `%s/%s`; %v", secretName, ch.ResourceNamespace, err) + } + fmt.Printf( "%v", secretObj ) + + // TODO: add code that sets a record in the DNS provider's console return nil }