mirror of
https://github.com/cert-manager/webhook-example.git
synced 2025-07-01 22:35:49 +02:00
changed group_name and fixed up removal of records. added quotes to value.
This commit is contained in:
parent
800668d59b
commit
0472ed4288
3 changed files with 24 additions and 10 deletions
|
@ -28,6 +28,8 @@ spec:
|
|||
- --tls-cert-file=/tls/tls.crt
|
||||
- --tls-private-key-file=/tls/tls.key
|
||||
- --secure-port=8043
|
||||
- --audit-log-path=-
|
||||
- -v=5
|
||||
env:
|
||||
- name: GROUP_NAME
|
||||
value: {{ .Values.groupName | quote }}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
# solve the DNS01 challenge.
|
||||
# This group name should be **unique**, hence using your own company's domain
|
||||
# here is recommended.
|
||||
groupName: acme.mycompany.com
|
||||
groupName: acme.powerdns.com
|
||||
|
||||
certManager:
|
||||
namespace: cert-manager
|
||||
|
@ -15,7 +15,7 @@ certManager:
|
|||
image:
|
||||
repository: quay.io/tidawson/pdns-webhook
|
||||
tag: latest
|
||||
pullPolicy: IfNotPresent
|
||||
pullPolicy: Always
|
||||
|
||||
nameOverride: ""
|
||||
fullnameOverride: ""
|
||||
|
|
28
main.go
28
main.go
|
@ -97,16 +97,15 @@ func (c *customDNSProviderSolver) Present(ch *v1alpha1.ChallengeRequest) error {
|
|||
}
|
||||
|
||||
// TODO: do something more useful with the decoded configuration
|
||||
fmt.Printf("Decoded configuration %v", cfg)
|
||||
fmt.Printf("Decoded configuration Key: %s, Server: %s\n", cfg.APIKey, cfg.Server)
|
||||
fmt.Printf("Presenting Record zone: %s, fqdn: %s, key: %s\n", ch.ResolvedZone, ch.ResolvedFQDN, ch.Key)
|
||||
|
||||
//TODO: get a client using a secret + kubeapi
|
||||
c.pdns = powerdns.NewClient(cfg.Server, "", map[string]string{"X-API-Key": cfg.APIKey}, nil)
|
||||
|
||||
if ch.Action == v1alpha1.ChallengeActionPresent {
|
||||
//Add: zone, record, type, ttl, value
|
||||
c.pdns.Records.Add(ch.ResolvedZone, ch.ResolvedFQDN, powerdns.RRTypeTXT, 10, []string{ch.Key})
|
||||
} else {
|
||||
c.pdns.Records.Delete(ch.ResolvedZone, ch.ResolvedFQDN, powerdns.RRTypeTXT)
|
||||
err = c.pdns.Records.Add(ch.ResolvedZone, ch.ResolvedFQDN, powerdns.RRTypeTXT, 10, []string{fmt.Sprintf(`"%s"`, ch.Key)})
|
||||
if err != nil {
|
||||
fmt.Printf("Error Adding Record: %v\n", err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -119,7 +118,20 @@ func (c *customDNSProviderSolver) Present(ch *v1alpha1.ChallengeRequest) error {
|
|||
// This is in order to facilitate multiple DNS validations for the same domain
|
||||
// concurrently.
|
||||
func (c *customDNSProviderSolver) CleanUp(ch *v1alpha1.ChallengeRequest) error {
|
||||
// TODO: add code that deletes a record from the DNS provider's console
|
||||
cfg, err := loadConfig(ch.Config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
//TODO: get a client using a secret + kubeapi
|
||||
c.pdns = powerdns.NewClient(cfg.Server, "", map[string]string{"X-API-Key": cfg.APIKey}, nil)
|
||||
|
||||
//TODO: check value before delete. for parrallel validation
|
||||
err = c.pdns.Records.Delete(ch.ResolvedZone, ch.ResolvedFQDN, powerdns.RRTypeTXT)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue