Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

designate: allow manually overwriting DNS zone #2204

Merged
merged 2 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/zz_gen_cmd_dnshelp.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,7 @@ func displayDNSHelp(w io.Writer, name string) error {
ew.writeln(` - "DESIGNATE_POLLING_INTERVAL": Time between DNS propagation check`)
ew.writeln(` - "DESIGNATE_PROPAGATION_TIMEOUT": Maximum waiting time for DNS propagation`)
ew.writeln(` - "DESIGNATE_TTL": The TTL of the TXT record used for the DNS challenge`)
ew.writeln(` - "DESIGNATE_ZONE_NAME": The zone name to use in the OpenStack Project to manage TXT records.`)
ew.writeln(` - "OS_PROJECT_ID": Project ID`)
ew.writeln(` - "OS_TENANT_NAME": Tenant name (deprecated see OS_PROJECT_NAME and OS_PROJECT_ID)`)

Expand Down
1 change: 1 addition & 0 deletions docs/content/dns/zz_gen_designate.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ More information [here]({{< ref "dns#configuration-and-credentials" >}}).
| `DESIGNATE_POLLING_INTERVAL` | Time between DNS propagation check |
| `DESIGNATE_PROPAGATION_TIMEOUT` | Maximum waiting time for DNS propagation |
| `DESIGNATE_TTL` | The TTL of the TXT record used for the DNS challenge |
| `DESIGNATE_ZONE_NAME` | The zone name to use in the OpenStack Project to manage TXT records. |
| `OS_PROJECT_ID` | Project ID |
| `OS_TENANT_NAME` | Tenant name (deprecated see OS_PROJECT_NAME and OS_PROJECT_ID) |

Expand Down
28 changes: 22 additions & 6 deletions providers/dns/designate/designate.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const (
EnvPropagationTimeout = envNamespace + "PROPAGATION_TIMEOUT"
EnvPollingInterval = envNamespace + "POLLING_INTERVAL"

EnvZoneName = envNamespace + "ZONE_NAME"

envNamespaceClient = "OS_"

EnvAuthURL = envNamespaceClient + "AUTH_URL"
Expand Down Expand Up @@ -127,12 +129,12 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
info := dns01.GetChallengeInfo(domain, keyAuth)

authZone, err := dns01.FindZoneByFqdn(info.EffectiveFQDN)
zone, err := getAuthZone(info.EffectiveFQDN)
if err != nil {
return fmt.Errorf("designate: could not find zone for domain %q: %w", domain, err)
return fmt.Errorf("designate: %w", err)
}

zoneID, err := d.getZoneID(authZone)
zoneID, err := d.getZoneID(zone)
if err != nil {
return fmt.Errorf("designate: couldn't get zone ID in Present: %w", err)
}
Expand Down Expand Up @@ -167,12 +169,12 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
info := dns01.GetChallengeInfo(domain, keyAuth)

authZone, err := dns01.FindZoneByFqdn(info.EffectiveFQDN)
zone, err := getAuthZone(info.EffectiveFQDN)
if err != nil {
return fmt.Errorf("designate: could not find zone for domain %q: %w", domain, err)
return fmt.Errorf("designate: %w", err)
}

zoneID, err := d.getZoneID(authZone)
zoneID, err := d.getZoneID(zone)
if err != nil {
return fmt.Errorf("designate: couldn't get zone ID in CleanUp: %w", err)
}
Expand Down Expand Up @@ -273,3 +275,17 @@ func (d *DNSProvider) getRecord(zoneID, wanted string) (*recordsets.RecordSet, e

return nil, nil
}

func getAuthZone(fqdn string) (string, error) {
authZone := env.GetOrFile(EnvZoneName)
if authZone != "" {
return authZone, nil
}

authZone, err := dns01.FindZoneByFqdn(fqdn)
if err != nil {
return "", fmt.Errorf("could not find zone: %w", err)
}

return authZone, nil
}
1 change: 1 addition & 0 deletions providers/dns/designate/designate.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Public cloud providers with support for Designate:
[Configuration.Additional]
OS_PROJECT_ID = "Project ID"
OS_TENANT_NAME = "Tenant name (deprecated see OS_PROJECT_NAME and OS_PROJECT_ID)"
DESIGNATE_ZONE_NAME = "The zone name to use in the OpenStack Project to manage TXT records."
DESIGNATE_POLLING_INTERVAL = "Time between DNS propagation check"
DESIGNATE_PROPAGATION_TIMEOUT = "Maximum waiting time for DNS propagation"
DESIGNATE_TTL = "The TTL of the TXT record used for the DNS challenge"
Expand Down