mirror of
https://github.com/cert-manager/webhook-example.git
synced 2026-03-17 02:12:51 +01:00
implement CleanUp method
This commit is contained in:
parent
4a6c892037
commit
b911dcf170
1 changed files with 15 additions and 2 deletions
17
main.go
17
main.go
|
|
@ -118,8 +118,21 @@ func (c *customDNSProviderSolver) Present(ch *acme_v1alpha1.ChallengeRequest) er
|
||||||
// This is in order to facilitate multiple DNS validations for the same domain
|
// This is in order to facilitate multiple DNS validations for the same domain
|
||||||
// concurrently.
|
// concurrently.
|
||||||
func (c *customDNSProviderSolver) CleanUp(ch *acme_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
|
cfg, err := loadConfig(ch.Config)
|
||||||
return nil
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
apiKeySecret, err := c.client.CoreV1().Secrets("").Get(context.TODO(), cfg.APIKeySecretRef.Name, v1.GetOptions{})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
apiKeyData := apiKeySecret.Data[cfg.APIKeySecretRef.Key]
|
||||||
|
apiKey := string(apiKeyData)
|
||||||
|
|
||||||
|
dnsName := strings.TrimSuffix(ch.ResolvedFQDN, "."+ch.ResolvedZone)
|
||||||
|
|
||||||
|
return dns.ClearTXTRecord(ch.ResolvedZone, dnsName, ch.Key, cfg.Login, apiKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize will be called when the webhook first starts.
|
// Initialize will be called when the webhook first starts.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue