diff --git a/commands/createDomains.go b/commands/createDomains.go index eab303bb9..dda82cfd0 100644 --- a/commands/createDomains.go +++ b/commands/createDomains.go @@ -54,9 +54,9 @@ func CreateDomains(args CreateDomainsArgs) error { for _, domain := range cfg.Domains { fmt.Println("*** ", domain.Name) for _, provider := range domain.DNSProviderInstances { - if creator, ok := provider.Driver.(providers.DomainCreator); ok { + if creator, ok := provider.Driver.(providers.ZoneCreator); ok { fmt.Println(" -", provider.Name) - err := creator.EnsureDomainExists(domain.Name) + err := creator.EnsureZoneExists(domain.Name) if err != nil { fmt.Printf("Error creating domain: %s\n", err) } diff --git a/commands/previewPush.go b/commands/previewPush.go index 9fd8e7dfd..1db00a92e 100644 --- a/commands/previewPush.go +++ b/commands/previewPush.go @@ -151,12 +151,12 @@ DomainLoop: out.Warnf("DEBUG: zones: %v\n", zones) out.Warnf("DEBUG: Name: %v\n", domain.Name) - out.Warnf("Domain '%s' does not exist in the '%s' profile and will be added automatically.\n", domain.Name, provider.Name) + out.Warnf("Zone '%s' does not exist in the '%s' profile and will be added automatically.\n", domain.Name, provider.Name) continue // continue with next provider, as we can not determine corrections without an existing zone } - } else if creator, ok := provider.Driver.(providers.DomainCreator); ok && push { + } else if creator, ok := provider.Driver.(providers.ZoneCreator); ok && push { // this is the actual push, ensure domain exists at DSP - if err := creator.EnsureDomainExists(domain.Name); err != nil { + if err := creator.EnsureZoneExists(domain.Name); err != nil { out.Warnf("Error creating domain: %s\n", err) continue // continue with next provider, as we couldn't create this one } diff --git a/providers/akamaiedgedns/akamaiEdgeDnsProvider.go b/providers/akamaiedgedns/akamaiEdgeDnsProvider.go index 8b35c7c4c..b1a55829a 100644 --- a/providers/akamaiedgedns/akamaiEdgeDnsProvider.go +++ b/providers/akamaiedgedns/akamaiEdgeDnsProvider.go @@ -95,8 +95,8 @@ func newEdgeDNSDSP(config map[string]string, metadata json.RawMessage) (provider return api, nil } -// EnsureDomainExists configures a new zone if the zone does not already exist. -func (a *edgeDNSProvider) EnsureDomainExists(domain string) error { +// EnsureZoneExists creates a zone if it does not exist +func (a *edgeDNSProvider) EnsureZoneExists(domain string) error { if zoneDoesExist(domain) { printer.Debugf("Zone %s already exists\n", domain) return nil diff --git a/providers/azuredns/azureDnsProvider.go b/providers/azuredns/azureDnsProvider.go index 79b048563..eb5353300 100644 --- a/providers/azuredns/azureDnsProvider.go +++ b/providers/azuredns/azureDnsProvider.go @@ -662,7 +662,7 @@ func (a *azurednsProvider) fetchRecordSets(zoneName string) ([]*adns.RecordSet, return records, nil } -func (a *azurednsProvider) EnsureDomainExists(domain string) error { +func (a *azurednsProvider) EnsureZoneExists(domain string) error { if _, ok := a.zones[domain]; ok { return nil } diff --git a/providers/cloudflare/cloudflareProvider.go b/providers/cloudflare/cloudflareProvider.go index 3f3458a00..f9e3f8fca 100644 --- a/providers/cloudflare/cloudflareProvider.go +++ b/providers/cloudflare/cloudflareProvider.go @@ -870,8 +870,8 @@ func getProxyMetadata(r *models.RecordConfig) map[string]string { } } -// EnsureDomainExists returns an error of domain does not exist. -func (c *cloudflareProvider) EnsureDomainExists(domain string) error { +// EnsureZoneExists creates a zone if it does not exist +func (c *cloudflareProvider) EnsureZoneExists(domain string) error { if c.domainIndex == nil { if err := c.fetchDomainList(); err != nil { return err diff --git a/providers/cloudns/cloudnsProvider.go b/providers/cloudns/cloudnsProvider.go index 6e556daf5..47c5f1bba 100644 --- a/providers/cloudns/cloudnsProvider.go +++ b/providers/cloudns/cloudnsProvider.go @@ -206,12 +206,12 @@ func (c *cloudnsProvider) GetZoneRecords(domain string) (models.Records, error) return existingRecords, nil } -// EnsureDomainExists returns an error if domain doesn't exist. -func (c *cloudnsProvider) EnsureDomainExists(domain string) error { +// EnsureZoneExists creates a zone if it does not exist +func (c *cloudnsProvider) EnsureZoneExists(domain string) error { if err := c.fetchDomainList(); err != nil { return err } - // domain already exists + // zone already exists if _, ok := c.domainIndex[domain]; ok { return nil } diff --git a/providers/desec/desecProvider.go b/providers/desec/desecProvider.go index d205a8699..c09fd39a5 100644 --- a/providers/desec/desecProvider.go +++ b/providers/desec/desecProvider.go @@ -112,9 +112,8 @@ func (c *desecProvider) GetZoneRecords(domain string) (models.Records, error) { return existingRecords, nil } -// EnsureDomainExists returns an error if domain doesn't exist. -func (c *desecProvider) EnsureDomainExists(domain string) error { - // domain already exists +// EnsureZoneExists creates a zone if it does not exist +func (c *desecProvider) EnsureZoneExists(domain string) error { c.mutex.Lock() defer c.mutex.Unlock() if _, ok := c.domainIndex[domain]; ok { diff --git a/providers/digitalocean/digitaloceanProvider.go b/providers/digitalocean/digitaloceanProvider.go index 9a2150871..688cc7a5c 100644 --- a/providers/digitalocean/digitaloceanProvider.go +++ b/providers/digitalocean/digitaloceanProvider.go @@ -87,8 +87,8 @@ func init() { providers.RegisterDomainServiceProviderType("DIGITALOCEAN", fns, features) } -// EnsureDomainExists returns an error if domain doesn't exist. -func (api *digitaloceanProvider) EnsureDomainExists(domain string) error { +// EnsureZoneExists creates a zone if it does not exist +func (api *digitaloceanProvider) EnsureZoneExists(domain string) error { retry: ctx := context.Background() _, resp, err := api.client.Domains.Get(ctx, domain) diff --git a/providers/dnsmadeeasy/dnsMadeEasyProvider.go b/providers/dnsmadeeasy/dnsMadeEasyProvider.go index 8bfb504d1..8dd04ccd6 100644 --- a/providers/dnsmadeeasy/dnsMadeEasyProvider.go +++ b/providers/dnsmadeeasy/dnsMadeEasyProvider.go @@ -177,9 +177,9 @@ func (api *dnsMadeEasyProvider) GetDomainCorrections(dc *models.DomainConfig) ([ return corrections, nil } -// EnsureDomainExists returns an error if domain doesn't exist. -func (api *dnsMadeEasyProvider) EnsureDomainExists(domainName string) error { - exists, err := api.domainExists(domainName) +// EnsureZoneExists creates a zone if it does not exist +func (api *dnsMadeEasyProvider) EnsureZoneExists(domain string) error { + exists, err := api.domainExists(domain) if err != nil { return err } @@ -189,7 +189,7 @@ func (api *dnsMadeEasyProvider) EnsureDomainExists(domainName string) error { return nil } - return api.createDomain(domainName) + return api.createDomain(domain) } // GetNameservers returns the nameservers for a domain. diff --git a/providers/exoscale/exoscaleProvider.go b/providers/exoscale/exoscaleProvider.go index f4e0c9036..9f0e98862 100644 --- a/providers/exoscale/exoscaleProvider.go +++ b/providers/exoscale/exoscaleProvider.go @@ -74,9 +74,9 @@ func init() { providers.RegisterDomainServiceProviderType("EXOSCALE", fns, features) } -// EnsureDomainExists returns an error if domain doesn't exist. -func (c *exoscaleProvider) EnsureDomainExists(domainName string) error { - _, err := c.findDomainByName(domainName) +// EnsureZoneExists creates a zone if it does not exist +func (c *exoscaleProvider) EnsureZoneExists(domain string) error { + _, err := c.findDomainByName(domain) return err } diff --git a/providers/gcloud/gcloudProvider.go b/providers/gcloud/gcloudProvider.go index 5a817e259..0aa5e21ec 100644 --- a/providers/gcloud/gcloudProvider.go +++ b/providers/gcloud/gcloudProvider.go @@ -327,7 +327,7 @@ func (g *gcloudProvider) getRecords(domain string) ([]*gdns.ResourceRecordSet, s return sets, zone.Name, nil } -func (g *gcloudProvider) EnsureDomainExists(domain string) error { +func (g *gcloudProvider) EnsureZoneExists(domain string) error { z, err := g.getZone(domain) if err != nil { if _, ok := err.(errNoExist); !ok { diff --git a/providers/gcore/gcoreProvider.go b/providers/gcore/gcoreProvider.go index 719310963..1c5ec2031 100644 --- a/providers/gcore/gcoreProvider.go +++ b/providers/gcore/gcoreProvider.go @@ -114,8 +114,8 @@ func (c *gcoreProvider) GetZoneRecords(domain string) (models.Records, error) { return existingRecords, nil } -// EnsureDomainExists returns an error if domain doesn't exist. -func (c *gcoreProvider) EnsureDomainExists(domain string) error { +// EnsureZoneExists creates a zone if it does not exist +func (c *gcoreProvider) EnsureZoneExists(domain string) error { zones, err := c.provider.Zones(c.ctx) if err != nil { return err diff --git a/providers/hedns/hednsProvider.go b/providers/hedns/hednsProvider.go index 4615e27db..f2429d74b 100644 --- a/providers/hedns/hednsProvider.go +++ b/providers/hedns/hednsProvider.go @@ -156,8 +156,8 @@ func (c *hednsProvider) ListZones() ([]string, error) { return domains, err } -// EnsureDomainExists creates the domain if it does not exist. -func (c *hednsProvider) EnsureDomainExists(domain string) error { +// EnsureZoneExists creates a zone if it does not exist +func (c *hednsProvider) EnsureZoneExists(domain string) error { domains, err := c.ListZones() if err != nil { return err diff --git a/providers/hetzner/hetznerProvider.go b/providers/hetzner/hetznerProvider.go index 2d25fe331..bfae4c3ef 100644 --- a/providers/hetzner/hetznerProvider.go +++ b/providers/hetzner/hetznerProvider.go @@ -61,8 +61,8 @@ func New(settings map[string]string, _ json.RawMessage) (providers.DNSServicePro return api, nil } -// EnsureDomainExists creates the domain if it does not exist. -func (api *hetznerProvider) EnsureDomainExists(domain string) error { +// EnsureZoneExists creates a zone if it does not exist +func (api *hetznerProvider) EnsureZoneExists(domain string) error { domains, err := api.ListZones() if err != nil { return err diff --git a/providers/hexonet/domains.go b/providers/hexonet/domains.go index d61e428dd..2dd22f06e 100644 --- a/providers/hexonet/domains.go +++ b/providers/hexonet/domains.go @@ -2,10 +2,10 @@ package hexonet import "fmt" -// EnsureDomainExists returns an error +// EnsureZoneExists returns an error // * if access to dnszone is not allowed (not authorized) or // * if it doesn't exist and creating it fails -func (n *HXClient) EnsureDomainExists(domain string) error { +func (n *HXClient) EnsureZoneExists(domain string) error { r := n.client.Request(map[string]interface{}{ "COMMAND": "StatusDNSZone", "DNSZONE": domain + ".", @@ -17,7 +17,7 @@ func (n *HXClient) EnsureDomainExists(domain string) error { "DNSZONE": domain + ".", }) if !r.IsSuccess() { - return n.GetHXApiError("Failed to create not existing zone for domain", domain, r) + return n.GetHXApiError("Failed to create not existing zone ", domain, r) } } else if code == 531 { return n.GetHXApiError("Not authorized to manage dnszone", domain, r) diff --git a/providers/hostingde/hostingdeProvider.go b/providers/hostingde/hostingdeProvider.go index 62842a47a..9d74713c9 100644 --- a/providers/hostingde/hostingdeProvider.go +++ b/providers/hostingde/hostingdeProvider.go @@ -351,7 +351,7 @@ func (hp *hostingdeProvider) GetRegistrarCorrections(dc *models.DomainConfig) ([ return nil, nil } -func (hp *hostingdeProvider) EnsureDomainExists(domain string) error { +func (hp *hostingdeProvider) EnsureZoneExists(domain string) error { _, err := hp.getZoneConfig(domain) if err == errZoneNotFound { if err := hp.createZone(domain); err != nil { diff --git a/providers/inwx/inwxProvider.go b/providers/inwx/inwxProvider.go index eac849081..265e1132f 100644 --- a/providers/inwx/inwxProvider.go +++ b/providers/inwx/inwxProvider.go @@ -399,8 +399,8 @@ func (api *inwxAPI) fetchNameserverDomains() error { return nil } -// EnsureDomainExists returns an error if domain does not exist. -func (api *inwxAPI) EnsureDomainExists(domain string) error { +// EnsureZoneExists creates a zone if it does not exist +func (api *inwxAPI) EnsureZoneExists(domain string) error { if api.domainIndex == nil { // only pull the data once. if err := api.fetchNameserverDomains(); err != nil { return err @@ -408,10 +408,10 @@ func (api *inwxAPI) EnsureDomainExists(domain string) error { } if _, ok := api.domainIndex[domain]; ok { - return nil // domain exists. + return nil // zone exists. } - // creating the domain. + // creating the zone. request := &goinwx.NameserverCreateRequest{ Domain: domain, Type: "MASTER", diff --git a/providers/ns1/ns1Provider.go b/providers/ns1/ns1Provider.go index d1cd36dff..81705320a 100644 --- a/providers/ns1/ns1Provider.go +++ b/providers/ns1/ns1Provider.go @@ -50,7 +50,7 @@ func newProvider(creds map[string]string, meta json.RawMessage) (providers.DNSSe return &nsone{rest.NewClient(http.DefaultClient, rest.SetAPIKey(creds["api_token"]))}, nil } -func (n *nsone) EnsureDomainExists(domain string) error { +func (n *nsone) EnsureZoneExists(domain string) error { // This enables the create-domains subcommand zone := dns.NewZone(domain) diff --git a/providers/oracle/oracleProvider.go b/providers/oracle/oracleProvider.go index bb88d4302..01ecef2ab 100644 --- a/providers/oracle/oracleProvider.go +++ b/providers/oracle/oracleProvider.go @@ -84,8 +84,8 @@ func (o *oracleProvider) ListZones() ([]string, error) { return zones, nil } -// EnsureDomainExists creates the domain if it does not exist. -func (o *oracleProvider) EnsureDomainExists(domain string) error { +// EnsureZoneExists creates a zone if it does not exist +func (o *oracleProvider) EnsureZoneExists(domain string) error { ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() diff --git a/providers/powerdns/dns.go b/providers/powerdns/dns.go index 24f834a0f..116c99e13 100644 --- a/providers/powerdns/dns.go +++ b/providers/powerdns/dns.go @@ -131,15 +131,15 @@ func (dsp *powerdnsProvider) GetDomainCorrections(dc *models.DomainConfig) ([]*m return corrections, nil } -// EnsureDomainExists adds a domain to the DNS service if it does not exist -func (dsp *powerdnsProvider) EnsureDomainExists(domain string) error { +// EnsureZoneExists creates a zone if it does not exist +func (dsp *powerdnsProvider) EnsureZoneExists(domain string) error { if _, err := dsp.client.Zones().GetZone(context.Background(), dsp.ServerName, domain+"."); err != nil { if e, ok := err.(pdnshttp.ErrUnexpectedStatus); ok { if e.StatusCode != http.StatusNotFound { return err } } - } else { // domain seems to be there + } else { // zone seems to exist return nil } diff --git a/providers/providers.go b/providers/providers.go index 42d850748..eaf11d5fe 100644 --- a/providers/providers.go +++ b/providers/providers.go @@ -18,10 +18,10 @@ type DNSServiceProvider interface { models.DNSProvider } -// DomainCreator should be implemented by providers that have the ability to add domains to an account. the create-domains command -// can be run to ensure all domains are present before running preview/push. Implement this only if the provider supoprts the `dnscontrol create-domain` command. -type DomainCreator interface { - EnsureDomainExists(domain string) error +// ZoneCreator should be implemented by providers that have the ability to create zones +// (used for automatically creating zones if they don't exist) +type ZoneCreator interface { + EnsureZoneExists(domain string) error } // ZoneLister should be implemented by providers that have the diff --git a/providers/route53/route53Provider.go b/providers/route53/route53Provider.go index 63979fd7e..d56f28f06 100644 --- a/providers/route53/route53Provider.go +++ b/providers/route53/route53Provider.go @@ -818,7 +818,7 @@ func unescape(s *string) string { return name } -func (r *route53Provider) EnsureDomainExists(domain string) error { +func (r *route53Provider) EnsureZoneExists(domain string) error { if err := r.getZones(); err != nil { return err } diff --git a/providers/vultr/vultrProvider.go b/providers/vultr/vultrProvider.go index 366cf91f5..e30611922 100644 --- a/providers/vultr/vultrProvider.go +++ b/providers/vultr/vultrProvider.go @@ -223,8 +223,8 @@ func (api *vultrProvider) GetNameservers(domain string) ([]*models.Nameserver, e return models.ToNameservers(defaultNS) } -// EnsureDomainExists adds a domain to the Vutr DNS service if it does not exist -func (api *vultrProvider) EnsureDomainExists(domain string) error { +// EnsureZoneExists creates a zone if it does not exist +func (api *vultrProvider) EnsureZoneExists(domain string) error { if ok, err := api.isDomainInAccount(domain); err != nil { return err } else if ok {