mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
NEW FEATURE: IGNORE() (diff2 only) (#2388)
Co-authored-by: Jeffrey Cafferata <jeffrey@jcid.nl>
This commit is contained in:
@@ -32,8 +32,8 @@ type DomainConfig struct {
|
||||
|
||||
IgnoredNames []*IgnoreName `json:"ignored_names,omitempty"`
|
||||
IgnoredTargets []*IgnoreTarget `json:"ignored_targets,omitempty"`
|
||||
Unmanaged []*UnmanagedConfig `json:"unmanaged,omitempty"` // UNMANAGED()
|
||||
UnmanagedUnsafe bool `json:"unmanaged_disable_safety_check,omitempty"` // DISABLE_UNMANAGED_SAFETY_CHECK
|
||||
Unmanaged []*UnmanagedConfig `json:"unmanaged,omitempty"` // IGNORE()
|
||||
UnmanagedUnsafe bool `json:"unmanaged_disable_safety_check,omitempty"` // DISABLE_IGNORE_SAFETY_CHECK
|
||||
|
||||
AutoDNSSEC string `json:"auto_dnssec,omitempty"` // "", "on", "off"
|
||||
//DNSSEC bool `json:"dnssec,omitempty"`
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
|
||||
"github.com/gobwas/glob"
|
||||
)
|
||||
|
||||
// UnmanagedConfig describes an UNMANAGED() rule.
|
||||
// UnmanagedConfig describes an IGNORE() rule.
|
||||
// NB(tlim): This is called "Unmanaged" because the original design
|
||||
// was to call this function UNMANAGED(). However we then realized
|
||||
// that we could repurpose IGNORE() without any compatibility issues.
|
||||
// NB(tlim): TechDebt: UnmanagedConfig and DebugUnmanagedConfig should
|
||||
// be moved to pkg/diff2/handsoff.go and the following fields could be
|
||||
// unexported: LabelGlob, RTypeMap, and TargetGlob
|
||||
type UnmanagedConfig struct {
|
||||
// Glob pattern for matching labels.
|
||||
LabelPattern string `json:"label_pattern,omitempty"`
|
||||
@@ -18,3 +27,26 @@ type UnmanagedConfig struct {
|
||||
TargetPattern string `json:"target_pattern,omitempty"`
|
||||
TargetGlob glob.Glob `json:"-"` // Compiled version
|
||||
}
|
||||
|
||||
// DebugUnmanagedConfig returns a string version of an []*UnmanagedConfig for debugging purposes.
|
||||
func DebugUnmanagedConfig(uc []*UnmanagedConfig) string {
|
||||
if len(uc) == 0 {
|
||||
return "UnmanagedConfig{}"
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
b := &buf
|
||||
|
||||
fmt.Fprint(b, "UnmanagedConfig{\n")
|
||||
for i, c := range uc {
|
||||
fmt.Fprintf(b, "%00d: (%v, %+v, %v)\n",
|
||||
i,
|
||||
c.LabelGlob,
|
||||
c.RTypeMap,
|
||||
c.TargetGlob,
|
||||
)
|
||||
}
|
||||
fmt.Fprint(b, "}")
|
||||
|
||||
return b.String()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user