mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
Refactor: Prelink providers to domains (#305)
This commit is contained in:
committed by
Tom Limoncelli
parent
b7c6efaa53
commit
7a4dca5ad5
@@ -21,9 +21,11 @@ const DefaultTTL = uint32(300)
|
||||
|
||||
// DNSConfig describes the desired DNS configuration, usually loaded from dnsconfig.js.
|
||||
type DNSConfig struct {
|
||||
Registrars []*RegistrarConfig `json:"registrars"`
|
||||
DNSProviders []*DNSProviderConfig `json:"dns_providers"`
|
||||
Domains []*DomainConfig `json:"domains"`
|
||||
Registrars []*RegistrarConfig `json:"registrars"`
|
||||
DNSProviders []*DNSProviderConfig `json:"dns_providers"`
|
||||
Domains []*DomainConfig `json:"domains"`
|
||||
RegistrarsByName map[string]*RegistrarConfig `json:"-"`
|
||||
DNSProvidersByName map[string]*DNSProviderConfig `json:"-"`
|
||||
}
|
||||
|
||||
// FindDomain returns the *DomainConfig for domain query in config.
|
||||
@@ -348,20 +350,41 @@ func StringsToNameservers(nss []string) []*Nameserver {
|
||||
|
||||
// DomainConfig describes a DNS domain (tecnically a DNS zone).
|
||||
type DomainConfig struct {
|
||||
Name string `json:"name"` // NO trailing "."
|
||||
Registrar string `json:"registrar"`
|
||||
DNSProviders map[string]int `json:"dnsProviders"`
|
||||
Name string `json:"name"` // NO trailing "."
|
||||
RegistrarName string `json:"registrar"`
|
||||
DNSProviderNames map[string]int `json:"dnsProviders"`
|
||||
|
||||
Metadata map[string]string `json:"meta,omitempty"`
|
||||
Records Records `json:"records"`
|
||||
Nameservers []*Nameserver `json:"nameservers,omitempty"`
|
||||
KeepUnknown bool `json:"keepunknown,omitempty"`
|
||||
IgnoredLabels []string `json:"ignored_labels,omitempty"`
|
||||
|
||||
// These fields contain instantiated provider instances once everything is linked up.
|
||||
// This linking is in two phases:
|
||||
// 1. Metadata (name/type) is availible just from the dnsconfig. Validation can use that.
|
||||
// 2. Final driver instances are loaded after we load credentials. Any actual provider interaction requires that.
|
||||
RegistrarInstance *RegistrarInstance `json:"-"`
|
||||
DNSProviderInstances []*DNSProviderInstance `json:"-"`
|
||||
}
|
||||
|
||||
// Copy returns a deep copy of the DomainConfig.
|
||||
func (dc *DomainConfig) Copy() (*DomainConfig, error) {
|
||||
newDc := &DomainConfig{}
|
||||
// provider instances are interfaces that gob hates if you don't register them.
|
||||
// and the specific types are not gob encodable since nothing is exported.
|
||||
// should find a better solution for this now.
|
||||
//
|
||||
// current strategy: remove everything, gob copy it. Then set both to stored copy.
|
||||
reg := dc.RegistrarInstance
|
||||
dnsps := dc.DNSProviderInstances
|
||||
dc.RegistrarInstance = nil
|
||||
dc.DNSProviderInstances = nil
|
||||
err := copyObj(dc, newDc)
|
||||
dc.RegistrarInstance = reg
|
||||
newDc.RegistrarInstance = reg
|
||||
dc.DNSProviderInstances = dnsps
|
||||
newDc.DNSProviderInstances = dnsps
|
||||
return newDc, err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user