implement CleanUp method

This commit is contained in:
Tevildo 2024-04-16 21:30:59 +01:00
parent 4a6c892037
commit b911dcf170
No known key found for this signature in database
GPG key ID: 780413157E8C9E35

17
main.go
View file

@ -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.