diff --git a/providers/dns/ibmcloud/internal/wrapper.go b/providers/dns/ibmcloud/internal/wrapper.go index 6129d9c1..dd89d1d4 100644 --- a/providers/dns/ibmcloud/internal/wrapper.go +++ b/providers/dns/ibmcloud/internal/wrapper.go @@ -2,6 +2,7 @@ package internal import ( "fmt" + "strings" "github.com/softlayer/softlayer-go/datatypes" "github.com/softlayer/softlayer-go/services" @@ -66,7 +67,16 @@ func getDomainID(service services.Dns_Domain, domain string) (*int, error) { return r.Id, nil } - return nil, fmt.Errorf("no data found of domain: %s", domain) + // The domain was not found by name. + // For subdomains this is not unusual in softlayer. + // So in case a subdomain like `sub.toplevel.tld` was used try again using the parent domain + // (strip the first part in the domain string -> `toplevel.tld`). + _, parent, found := strings.Cut(domain, ".") + if !found || !strings.Contains(parent, ".") { + return nil, fmt.Errorf("no data found for domain: %s", domain) + } + + return getDomainID(service, parent) } func findTxtRecords(service services.Dns_Domain, fqdn string) ([]datatypes.Dns_Domain_ResourceRecord, error) {