From 9873b9b8976a4701a51be398eda5992771072f78 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Sat, 20 Jul 2024 16:01:18 +0200 Subject: [PATCH] bluecat: skip deploy (#2230) --- cmd/zz_gen_cmd_dnshelp.go | 1 + docs/content/dns/zz_gen_bluecat.md | 1 + providers/dns/bluecat/bluecat.go | 21 ++++++++++++++------- providers/dns/bluecat/bluecat.toml | 1 + 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/cmd/zz_gen_cmd_dnshelp.go b/cmd/zz_gen_cmd_dnshelp.go index 899f8daa..fd59f7ac 100644 --- a/cmd/zz_gen_cmd_dnshelp.go +++ b/cmd/zz_gen_cmd_dnshelp.go @@ -372,6 +372,7 @@ func displayDNSHelp(w io.Writer, name string) error { ew.writeln(` - "BLUECAT_HTTP_TIMEOUT": API request timeout`) ew.writeln(` - "BLUECAT_POLLING_INTERVAL": Time between DNS propagation check`) ew.writeln(` - "BLUECAT_PROPAGATION_TIMEOUT": Maximum waiting time for DNS propagation`) + ew.writeln(` - "BLUECAT_SKIP_DEPLOY": Skip deployements`) ew.writeln(` - "BLUECAT_TTL": The TTL of the TXT record used for the DNS challenge`) ew.writeln() diff --git a/docs/content/dns/zz_gen_bluecat.md b/docs/content/dns/zz_gen_bluecat.md index 80a8fb8a..807d502e 100644 --- a/docs/content/dns/zz_gen_bluecat.md +++ b/docs/content/dns/zz_gen_bluecat.md @@ -59,6 +59,7 @@ More information [here]({{< ref "dns#configuration-and-credentials" >}}). | `BLUECAT_HTTP_TIMEOUT` | API request timeout | | `BLUECAT_POLLING_INTERVAL` | Time between DNS propagation check | | `BLUECAT_PROPAGATION_TIMEOUT` | Maximum waiting time for DNS propagation | +| `BLUECAT_SKIP_DEPLOY` | Skip deployements | | `BLUECAT_TTL` | The TTL of the TXT record used for the DNS challenge | The environment variable names can be suffixed by `_FILE` to reference a file instead of a value. diff --git a/providers/dns/bluecat/bluecat.go b/providers/dns/bluecat/bluecat.go index 58ac2147..ad7add9f 100644 --- a/providers/dns/bluecat/bluecat.go +++ b/providers/dns/bluecat/bluecat.go @@ -24,6 +24,7 @@ const ( EnvConfigName = envNamespace + "CONFIG_NAME" EnvDNSView = envNamespace + "DNS_VIEW" EnvDebug = envNamespace + "DEBUG" + EnvSkipDeploy = envNamespace + "SKIP_DEPLOY" EnvTTL = envNamespace + "TTL" EnvPropagationTimeout = envNamespace + "PROPAGATION_TIMEOUT" @@ -43,6 +44,7 @@ type Config struct { TTL int HTTPClient *http.Client Debug bool + SkipDeploy bool } // NewDefaultConfig returns a default configuration for the DNSProvider. @@ -54,7 +56,8 @@ func NewDefaultConfig() *Config { HTTPClient: &http.Client{ Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second), }, - Debug: env.GetOrDefaultBool(EnvDebug, false), + Debug: env.GetOrDefaultBool(EnvDebug, false), + SkipDeploy: env.GetOrDefaultBool(EnvSkipDeploy, false), } } @@ -143,9 +146,11 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { return fmt.Errorf("bluecat: add TXT record: %w", err) } - err = d.client.Deploy(ctx, parentZoneID) - if err != nil { - return fmt.Errorf("bluecat: deploy: %w", err) + if !d.config.SkipDeploy { + err = d.client.Deploy(ctx, parentZoneID) + if err != nil { + return fmt.Errorf("bluecat: deploy: %w", err) + } } err = d.client.Logout(ctx) @@ -185,9 +190,11 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { return fmt.Errorf("bluecat: delete TXT record: %w", err) } - err = d.client.Deploy(ctx, parentZoneID) - if err != nil { - return fmt.Errorf("bluecat: deploy: %w", err) + if !d.config.SkipDeploy { + err = d.client.Deploy(ctx, parentZoneID) + if err != nil { + return fmt.Errorf("bluecat: deploy: %w", err) + } } err = d.client.Logout(ctx) diff --git a/providers/dns/bluecat/bluecat.toml b/providers/dns/bluecat/bluecat.toml index f1094aec..11a2f0e2 100644 --- a/providers/dns/bluecat/bluecat.toml +++ b/providers/dns/bluecat/bluecat.toml @@ -26,6 +26,7 @@ lego --email you@example.com --dns bluecat --domains my.example.org run BLUECAT_PROPAGATION_TIMEOUT = "Maximum waiting time for DNS propagation" BLUECAT_TTL = "The TTL of the TXT record used for the DNS challenge" BLUECAT_HTTP_TIMEOUT = "API request timeout" + BLUECAT_SKIP_DEPLOY = "Skip deployements" [Links] API = "https://docs.bluecatnetworks.com/r/Address-Manager-API-Guide/REST-API/9.1.0"