mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
ns1: Implement EnsureDomainExists (#1157)
API support is there, let's use it. Co-authored-by: Tom Limoncelli <tlimoncelli@stackoverflow.com>
This commit is contained in:
@@ -19,7 +19,7 @@ var docNotes = providers.DocumentationNotes{
|
||||
providers.CanUseAlias: providers.Can(),
|
||||
providers.CanUseCAA: providers.Can(),
|
||||
providers.CanUsePTR: providers.Can(),
|
||||
providers.DocCreateDomains: providers.Cannot(),
|
||||
providers.DocCreateDomains: providers.Can(),
|
||||
providers.DocDualHost: providers.Can(),
|
||||
providers.DocOfficiallySupported: providers.Cannot(),
|
||||
}
|
||||
@@ -44,6 +44,20 @@ 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 {
|
||||
// This enables the create-domains subcommand
|
||||
|
||||
zone := dns.NewZone(domain)
|
||||
_, err := n.Zones.Create(zone)
|
||||
|
||||
if err == rest.ErrZoneExists {
|
||||
// if domain exists already, just return nil, nothing to do here.
|
||||
return nil
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (n *nsone) GetNameservers(domain string) ([]*models.Nameserver, error) {
|
||||
z, _, err := n.Zones.Get(domain)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user