Skip to content

Commit c754882

Browse files
thomasmhofmannldez
andauthored
ibmcloud: add support for subdomains (#1779)
Co-authored-by: Ludovic Fernandez <[email protected]>
1 parent 7095aa6 commit c754882

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

providers/dns/ibmcloud/internal/wrapper.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package internal
22

33
import (
44
"fmt"
5+
"strings"
56

67
"github.com/softlayer/softlayer-go/datatypes"
78
"github.com/softlayer/softlayer-go/services"
@@ -66,7 +67,16 @@ func getDomainID(service services.Dns_Domain, domain string) (*int, error) {
6667
return r.Id, nil
6768
}
6869

69-
return nil, fmt.Errorf("no data found of domain: %s", domain)
70+
// The domain was not found by name.
71+
// For subdomains this is not unusual in softlayer.
72+
// So in case a subdomain like `sub.toplevel.tld` was used try again using the parent domain
73+
// (strip the first part in the domain string -> `toplevel.tld`).
74+
_, parent, found := strings.Cut(domain, ".")
75+
if !found || !strings.Contains(parent, ".") {
76+
return nil, fmt.Errorf("no data found for domain: %s", domain)
77+
}
78+
79+
return getDomainID(service, parent)
7080
}
7181

7282
func findTxtRecords(service services.Dns_Domain, fqdn string) ([]datatypes.Dns_Domain_ResourceRecord, error) {

0 commit comments

Comments
 (0)