From 68842b3b701f8bba60b8bced5de3013616ffe91a Mon Sep 17 00:00:00 2001 From: chrisbulgaria <54033534+chrisbulgaria@users.noreply.github.com> Date: Wed, 11 Mar 2020 11:59:08 +0100 Subject: [PATCH] oraclecloud: fix subdomain support (#1055) --- providers/dns/oraclecloud/oraclecloud.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/providers/dns/oraclecloud/oraclecloud.go b/providers/dns/oraclecloud/oraclecloud.go index bcd0c058..c48a6291 100644 --- a/providers/dns/oraclecloud/oraclecloud.go +++ b/providers/dns/oraclecloud/oraclecloud.go @@ -85,6 +85,11 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) { func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) + zoneNameOrID, err1 := dns01.FindZoneByFqdn(dns01.ToFqdn(domain)) + if err1 != nil { + return fmt.Errorf("oraclecloud: could not find zone for domain %q and fqdn %q : %w", domain, fqdn, err1) + } + // generate request to dns.PatchDomainRecordsRequest recordOperation := dns.RecordOperation{ Domain: common.String(dns01.UnFqdn(fqdn)), @@ -96,7 +101,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { request := dns.PatchDomainRecordsRequest{ CompartmentId: common.String(d.config.CompartmentID), - ZoneNameOrId: common.String(domain), + ZoneNameOrId: common.String(zoneNameOrID), Domain: common.String(dns01.UnFqdn(fqdn)), PatchDomainRecordsDetails: dns.PatchDomainRecordsDetails{ Items: []dns.RecordOperation{recordOperation}, @@ -115,9 +120,14 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) + zoneNameOrID, err1 := dns01.FindZoneByFqdn(dns01.ToFqdn(domain)) + if err1 != nil { + return fmt.Errorf("oraclecloud: could not find zone for domain %q and fqdn %q : %w", domain, fqdn, err1) + } + // search to TXT record's hash to delete getRequest := dns.GetDomainRecordsRequest{ - ZoneNameOrId: common.String(domain), + ZoneNameOrId: common.String(zoneNameOrID), Domain: common.String(dns01.UnFqdn(fqdn)), CompartmentId: common.String(d.config.CompartmentID), Rtype: common.String("TXT"), @@ -152,7 +162,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { } patchRequest := dns.PatchDomainRecordsRequest{ - ZoneNameOrId: common.String(domain), + ZoneNameOrId: common.String(zoneNameOrID), Domain: common.String(dns01.UnFqdn(fqdn)), PatchDomainRecordsDetails: dns.PatchDomainRecordsDetails{ Items: []dns.RecordOperation{recordOperation},