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

Add IGNORE(label) which ignores label at the provider (#183) (#300)

* Add support for the IGNORE(name) directive (#183)

IGNORE is like NO_PURGE but for a spefic record instead of the whole
zone. This is very useful for instance if you have a zone where
only some records are managed externally from dnscontrol (for instance
using kubernetes external dns system).

Adding IGNORE("foo") in the zone will make dnscontrol not trying
to manage the "foo" record (and especially not deleting it).
dnscontrol will error out if the "foo" record is both ignored and
managed in dnscontrol.

This can be seen as a generic Cloudflare's ignored label.

Signed-off-by: Brice Figureau <brice@daysofwonder.com>

* Deprecate CloudFlare ignoredLabels in favor of IGNORE (#183)

Since IGNORE implements a generic `ignoredLabels` system, let
the user know CF `ignoredLabels` are deprecated.

Signed-off-by: Brice Figureau <brice@daysofwonder.com>
This commit is contained in:
Brice Figureau
2018-01-15 21:39:29 +01:00
committed by Tom Limoncelli
parent 79983f3493
commit 2fc55dfdc4
10 changed files with 242 additions and 103 deletions

View File

@@ -112,6 +112,7 @@ func runTests(t *testing.T, prv providers.DNSServiceProvider, domainName string,
}
dom.Records = append(dom.Records, &rc)
}
dom.IgnoredLabels = tst.IgnoredLabels
models.PostProcessRecords(dom.Records)
dom2, _ := dom.Copy()
// get corrections for first time
@@ -196,8 +197,9 @@ func TestDualProviders(t *testing.T) {
}
type TestCase struct {
Desc string
Records []*rec
Desc string
Records []*rec
IgnoredLabels []string
}
type rec models.RecordConfig
@@ -266,6 +268,13 @@ func tlsa(name string, usage, selector, matchingtype uint8, target string) *rec
return r
}
func ignore(name string) *rec {
return &rec{
Name: name,
Type: "IGNORE",
}
}
func makeRec(name, target, typ string) *rec {
return &rec{
Name: name,
@@ -281,9 +290,19 @@ func (r *rec) ttl(t uint32) *rec {
}
func tc(desc string, recs ...*rec) *TestCase {
var records []*rec
var ignored []string
for _, r := range recs {
if r.Type == "IGNORE" {
ignored = append(ignored, r.Name)
} else {
records = append(records, r)
}
}
return &TestCase{
Desc: desc,
Records: recs,
Desc: desc,
Records: records,
IgnoredLabels: ignored,
}
}
@@ -480,5 +499,12 @@ func makeTests(t *testing.T) []*TestCase {
)
}
// ignored recrods
tests = append(tests,
tc("Empty"),
tc("Create some records", txt("foo", "simple"), a("foo", "1.2.3.4")),
tc("Add a new record - ignoring foo", a("bar", "1.2.3.4"), ignore("foo")),
)
return tests
}