forked from TrueCloudLab/lego
ibmcloud: add support for subdomains (#1779)
Co-authored-by: Ludovic Fernandez <ldez@users.noreply.github.com>
This commit is contained in:
parent
7095aa66a2
commit
c754882704
1 changed files with 11 additions and 1 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue