mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
Bugfixed: NO_PURGE now works on all diff2 providers (#2084)
This commit is contained in:
@@ -19,11 +19,13 @@ type DomainConfig struct {
|
||||
Records Records `json:"records"`
|
||||
Nameservers []*Nameserver `json:"nameservers,omitempty"`
|
||||
|
||||
KeepUnknown bool `json:"keepunknown,omitempty"`
|
||||
EnsureAbsent Records `json:"recordsabsent,omitempty"` // ENSURE_ABSENT
|
||||
KeepUnknown bool `json:"keepunknown,omitempty"` // NO_PURGE
|
||||
|
||||
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"`
|
||||
Unmanaged []*UnmanagedConfig `json:"unmanaged,omitempty"` // UNMANAGED()
|
||||
UnmanagedUnsafe bool `json:"unmanaged_disable_safety_check,omitempty"` // DISABLE_UNMANAGED_SAFETY_CHECK
|
||||
|
||||
AutoDNSSEC string `json:"auto_dnssec,omitempty"` // "", "on", "off"
|
||||
//DNSSEC bool `json:"dnssec,omitempty"`
|
||||
@@ -36,14 +38,6 @@ 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{}
|
||||
|
@@ -184,6 +184,9 @@ func (rc *RecordConfig) UnmarshalJSON(b []byte) error {
|
||||
TxtStrings []string `json:"txtstrings,omitempty"` // TxtStrings stores all strings (including the first). Target stores only the first one.
|
||||
R53Alias map[string]string `json:"r53_alias,omitempty"`
|
||||
AzureAlias map[string]string `json:"azure_alias,omitempty"`
|
||||
|
||||
EnsureAbsent bool `json:"ensure_absent,omitempty"` // Override NO_PURGE and delete this record
|
||||
|
||||
// NB(tlim): If anyone can figure out how to do this without listing all
|
||||
// the fields, please let us know!
|
||||
}{}
|
||||
|
30
models/recorddb.go
Normal file
30
models/recorddb.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package models
|
||||
|
||||
// Functions that make it easier to deal with a group of records.
|
||||
|
||||
type RecordDB struct {
|
||||
labelAndTypeMap map[RecordKey]struct{}
|
||||
}
|
||||
|
||||
// NewRecordDBFromRecords creates a RecordDB from a list of RecordConfig.
|
||||
func NewRecordDBFromRecords(recs Records, zone string) *RecordDB {
|
||||
result := &RecordDB{}
|
||||
|
||||
//fmt.Printf("DEBUG: BUILDING RecordDB: zone=%v\n", zone)
|
||||
result.labelAndTypeMap = make(map[RecordKey]struct{}, len(recs))
|
||||
for _, rec := range recs {
|
||||
//fmt.Printf(" DEBUG: Adding %+v\n", rec.Key())
|
||||
result.labelAndTypeMap[rec.Key()] = struct{}{}
|
||||
}
|
||||
//fmt.Printf("DEBUG: BUILDING RecordDB: DONE!\n")
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// ContainsLT returns true if recdb contains rec. Matching is done
|
||||
// on the record's label and type (i.e. the RecordKey)
|
||||
func (recdb *RecordDB) ContainsLT(rec *RecordConfig) bool {
|
||||
_, ok := recdb.labelAndTypeMap[rec.Key()]
|
||||
//fmt.Printf("DEBUG: ContainsLT(%q) = %v (%v)\n", rec.Key(), ok, recdb)
|
||||
return ok
|
||||
}
|
20
models/unmanaged.go
Normal file
20
models/unmanaged.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/gobwas/glob"
|
||||
)
|
||||
|
||||
// UnmanagedConfig describes an UNMANAGED() rule.
|
||||
type UnmanagedConfig struct {
|
||||
// Glob pattern for matching labels.
|
||||
LabelPattern string `json:"label_pattern,omitempty"`
|
||||
LabelGlob glob.Glob `json:"-"` // Compiled version
|
||||
|
||||
// Comma-separated list of DNS Resource Types.
|
||||
RTypePattern string `json:"rType_pattern,omitempty"`
|
||||
RTypeMap map[string]struct{} `json:"-"` // map of RTypes or len()=0 for all
|
||||
|
||||
// Glob pattern for matching targets.
|
||||
TargetPattern string `json:"target_pattern,omitempty"`
|
||||
TargetGlob glob.Glob `json:"-"` // Compiled version
|
||||
}
|
Reference in New Issue
Block a user