bluecat: skip deploy (#2230)

This commit is contained in:
Ludovic Fernandez 2024-07-20 16:01:18 +02:00 committed by GitHub
parent 04864ff13b
commit 9873b9b897
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 7 deletions

View file

@ -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()

View file

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

View file

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

View file

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