diff --git a/main.go b/main.go index 969e6d2..2e5359a 100644 --- a/main.go +++ b/main.go @@ -6,10 +6,12 @@ import ( "os" extapi "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" - "github.com/cert-manager/cert-manager/pkg/acme/webhook/apis/acme/v1alpha1" + acme_v1alpha1 "github.com/cert-manager/cert-manager/pkg/acme/webhook/apis/acme/v1alpha1" "github.com/cert-manager/cert-manager/pkg/acme/webhook/cmd" + meta_v1 "github.com/cert-manager/cert-manager/pkg/apis/meta/v1" ) var GroupName = os.Getenv("GROUP_NAME") @@ -40,7 +42,7 @@ type customDNSProviderSolver struct { // 3. uncomment the relevant code in the Initialize method below // 4. ensure your webhook's service account has the required RBAC role // assigned to it for interacting with the Kubernetes APIs you need. - //client kubernetes.Clientset + client *kubernetes.Clientset } // customDNSProviderConfig is a structure that is used to decode into when @@ -64,7 +66,8 @@ type customDNSProviderConfig struct { // `issuer.spec.acme.dns01.providers.webhook.config` field. //Email string `json:"email"` - //APIKeySecretRef v1alpha1.SecretKeySelector `json:"apiKeySecretRef"` + Login string `json:"login"` + APIKeySecretRef meta_v1.SecretKeySelector `json:"apiKeySecretRef"` } // Name is used as the name for this DNS solver when referencing it on the ACME @@ -74,7 +77,7 @@ type customDNSProviderConfig struct { // within a single webhook deployment**. // For example, `cloudflare` may be used as the name of a solver. func (c *customDNSProviderSolver) Name() string { - return "my-custom-solver" + return "NearlyFreeSpeech" } // Present is responsible for actually presenting the DNS record with the @@ -82,7 +85,7 @@ func (c *customDNSProviderSolver) Name() string { // This method should tolerate being called multiple times with the same value. // cert-manager itself will later perform a self check to ensure that the // solver has correctly configured the DNS provider. -func (c *customDNSProviderSolver) Present(ch *v1alpha1.ChallengeRequest) error { +func (c *customDNSProviderSolver) Present(ch *acme_v1alpha1.ChallengeRequest) error { cfg, err := loadConfig(ch.Config) if err != nil { return err @@ -92,6 +95,7 @@ func (c *customDNSProviderSolver) Present(ch *v1alpha1.ChallengeRequest) error { fmt.Printf("Decoded configuration %v", cfg) // TODO: add code that sets a record in the DNS provider's console + return nil } @@ -101,7 +105,7 @@ func (c *customDNSProviderSolver) Present(ch *v1alpha1.ChallengeRequest) error { // value provided on the ChallengeRequest should be cleaned up. // This is in order to facilitate multiple DNS validations for the same domain // concurrently. -func (c *customDNSProviderSolver) CleanUp(ch *v1alpha1.ChallengeRequest) error { +func (c *customDNSProviderSolver) CleanUp(ch *acme_v1alpha1.ChallengeRequest) error { // TODO: add code that deletes a record from the DNS provider's console return nil } @@ -119,12 +123,12 @@ func (c *customDNSProviderSolver) Initialize(kubeClientConfig *rest.Config, stop ///// UNCOMMENT THE BELOW CODE TO MAKE A KUBERNETES CLIENTSET AVAILABLE TO ///// YOUR CUSTOM DNS PROVIDER - //cl, err := kubernetes.NewForConfig(kubeClientConfig) - //if err != nil { - // return err - //} - // - //c.client = cl + cl, err := kubernetes.NewForConfig(kubeClientConfig) + if err != nil { + return err + } + + c.client = cl ///// END OF CODE TO MAKE KUBERNETES CLIENTSET AVAILABLE return nil