1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

ROUTE53/GCLOUD: Add Delegation/nameserver Sets (#448)

- Support DelegationSet for Route53 (create-domains only)
- Retry Route53 operations which fail for rate limits under large numbers of domains
- Support for name_server_set for GCloud (create-domains only)
- Docs for both
This commit is contained in:
Riley Berton
2019-02-19 12:30:39 -05:00
committed by Tom Limoncelli
parent d4947fce23
commit 82d4660816
4 changed files with 157 additions and 33 deletions

View File

@@ -25,18 +25,23 @@ var features = providers.DocumentationNotes{
providers.CanUseTXTMulti: providers.Can(),
}
func sPtr(s string) *string {
return &s
}
func init() {
providers.RegisterDomainServiceProviderType("GCLOUD", New, features)
}
type gcloud struct {
client *gdns.Service
project string
zones map[string]*gdns.ManagedZone
client *gdns.Service
project string
nameServerSet *string
zones map[string]*gdns.ManagedZone
}
// New creates a new gcloud provider
func New(cfg map[string]string, _ json.RawMessage) (providers.DNSServiceProvider, error) {
func New(cfg map[string]string, metadata json.RawMessage) (providers.DNSServiceProvider, error) {
raw, err := json.Marshal(cfg)
if err != nil {
return nil, err
@@ -51,9 +56,15 @@ func New(cfg map[string]string, _ json.RawMessage) (providers.DNSServiceProvider
if err != nil {
return nil, err
}
var nss *string = nil
if val, ok := cfg["name_server_set"]; ok {
fmt.Printf("GCLOUD :name_server_set %s configured\n", val)
nss = sPtr(val)
}
return &gcloud{
client: dcli,
project: cfg["project_id"],
client: dcli,
nameServerSet: nss,
project: cfg["project_id"],
}, nil
}
@@ -231,11 +242,22 @@ func (g *gcloud) EnsureDomainExists(domain string) error {
if z != nil {
return nil
}
fmt.Printf("Adding zone for %s to gcloud account\n", domain)
mz := &gdns.ManagedZone{
DnsName: domain + ".",
Name: "zone-" + strings.Replace(domain, ".", "-", -1),
Description: "zone added by dnscontrol",
var mz *gdns.ManagedZone
if g.nameServerSet != nil {
fmt.Printf("Adding zone for %s to gcloud account with name_server_set %s\n", domain, *g.nameServerSet)
mz = &gdns.ManagedZone{
DnsName: domain + ".",
NameServerSet: *g.nameServerSet,
Name: "zone-" + strings.Replace(domain, ".", "-", -1),
Description: "zone added by dnscontrol",
}
} else {
fmt.Printf("Adding zone for %s to gcloud account \n", domain)
mz = &gdns.ManagedZone{
DnsName: domain + ".",
Name: "zone-" + strings.Replace(domain, ".", "-", -1),
Description: "zone added by dnscontrol",
}
}
g.zones = nil // reset cache
_, err = g.client.ManagedZones.Create(g.project, mz).Do()