mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
NEW FEATURE: diff2: A better "diff" mechanism (#1852)
This commit is contained in:
@@ -15,13 +15,17 @@ type DomainConfig struct {
|
||||
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"`
|
||||
IgnoredNames []*IgnoreName `json:"ignored_names,omitempty"`
|
||||
IgnoredTargets []*IgnoreTarget `json:"ignored_targets,omitempty"`
|
||||
AutoDNSSEC string `json:"auto_dnssec,omitempty"` // "", "on", "off"
|
||||
Metadata map[string]string `json:"meta,omitempty"`
|
||||
Records Records `json:"records"`
|
||||
Nameservers []*Nameserver `json:"nameservers,omitempty"`
|
||||
|
||||
KeepUnknown bool `json:"keepunknown,omitempty"`
|
||||
IgnoredNames []*IgnoreName `json:"ignored_names,omitempty"`
|
||||
IgnoredTargets []*IgnoreTarget `json:"ignored_targets,omitempty"`
|
||||
Unmanaged []*UnmanagedConfig `json:"unmanaged,omitempty"`
|
||||
UnmanagedUnsafe bool `json:"unmanaged_disable_safety_check,omitempty"`
|
||||
|
||||
AutoDNSSEC string `json:"auto_dnssec,omitempty"` // "", "on", "off"
|
||||
//DNSSEC bool `json:"dnssec,omitempty"`
|
||||
|
||||
// These fields contain instantiated provider instances once everything is linked up.
|
||||
@@ -32,6 +36,14 @@ type DomainConfig struct {
|
||||
DNSProviderInstances []*DNSProviderInstance `json:"-"`
|
||||
}
|
||||
|
||||
// UnmanagedConfig describes an UNMANAGED() rule.
|
||||
type UnmanagedConfig struct {
|
||||
Label string `json:"label_pattern"` // Glob pattern for matching labels.
|
||||
RType string `json:"rType_pattern"` // Comma-separated list of DNS Resource Types.
|
||||
typeMap map[string]bool // map of RTypes or len()=0 for all
|
||||
Target string `json:"target_pattern"` // Glob pattern for matching targets.
|
||||
}
|
||||
|
||||
// Copy returns a deep copy of the DomainConfig.
|
||||
func (dc *DomainConfig) Copy() (*DomainConfig, error) {
|
||||
newDc := &DomainConfig{}
|
||||
|
||||
@@ -305,10 +305,13 @@ func (rc *RecordConfig) GetLabelFQDN() string {
|
||||
// ToDiffable returns a string that is comparable by a differ.
|
||||
// extraMaps: a list of maps that should be included in the comparison.
|
||||
func (rc *RecordConfig) ToDiffable(extraMaps ...map[string]string) string {
|
||||
content := fmt.Sprintf("%v ttl=%d", rc.GetTargetCombined(), rc.TTL)
|
||||
if rc.Type == "SOA" {
|
||||
var content string
|
||||
switch rc.Type {
|
||||
case "SOA":
|
||||
content = fmt.Sprintf("%s %v %d %d %d %d ttl=%d", rc.target, rc.SoaMbox, rc.SoaRefresh, rc.SoaRetry, rc.SoaExpire, rc.SoaMinttl, rc.TTL)
|
||||
// SoaSerial is not used in comparison
|
||||
default:
|
||||
content = fmt.Sprintf("%v ttl=%d", rc.GetTargetCombined(), rc.TTL)
|
||||
}
|
||||
for _, valueMap := range extraMaps {
|
||||
// sort the extra values map keys to perform a deterministic
|
||||
@@ -424,6 +427,10 @@ type RecordKey struct {
|
||||
Type string
|
||||
}
|
||||
|
||||
func (rk *RecordKey) String() string {
|
||||
return rk.NameFQDN + ":" + rk.Type
|
||||
}
|
||||
|
||||
// Key converts a RecordConfig into a RecordKey.
|
||||
func (rc *RecordConfig) Key() RecordKey {
|
||||
t := rc.Type
|
||||
|
||||
Reference in New Issue
Block a user