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

ibmcloud: add support for subdomains #1779

Merged
merged 6 commits into from
Dec 6, 2022
Merged
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
12 changes: 11 additions & 1 deletion providers/dns/ibmcloud/internal/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package internal

import (
"fmt"
"strings"

"github.com/softlayer/softlayer-go/datatypes"
"github.com/softlayer/softlayer-go/services"
Expand Down Expand Up @@ -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) {
Expand Down