1
0
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:
Tom Limoncelli
2022-12-11 17:28:58 -05:00
committed by GitHub
parent b0f2945510
commit 54fc2e9ce3
40 changed files with 2581 additions and 81 deletions

View File

@@ -109,6 +109,7 @@ function newDomain(name, registrar) {
nameservers: [],
ignored_names: [],
ignored_targets: [],
unmanaged: [],
};
}
@@ -610,6 +611,11 @@ function IGNORE_NAME(name, rTypes) {
}
return function (d) {
d.ignored_names.push({ pattern: name, types: rTypes });
d.unmanaged.push({
label_pattern: name,
rType_pattern: rTypes,
target_pattern: '*',
});
};
}
@@ -622,10 +628,14 @@ var IGNORE_NAME_DISABLE_SAFETY_CHECK = {
// See https://github.com/StackExchange/dnscontrol/issues/1106
};
// IGNORE_TARGET(target, rType)
function IGNORE_TARGET(target, rType) {
return function (d) {
d.ignored_targets.push({ pattern: target, type: rType });
d.unmanaged.push({
label_pattern: '*',
rType_pattern: rType,
target_pattern: target,
});
};
}
@@ -667,6 +677,34 @@ function AUTODNSSEC(d) {
);
}
function UNMANAGED(label_pattern, rType_pattern, target_pattern) {
if (rType_pattern === undefined) {
rType_pattern = '*';
}
if (rType_pattern === "") {
rType_pattern = '*';
}
if (target_pattern === undefined) {
target_pattern = '*';
}
return function (d) {
d.unmanaged.push({
label_pattern: label_pattern,
rType_pattern: rType_pattern,
target_pattern: target_pattern,
});
};
}
function DISABLE_UNMANAGED_SAFETY_CHECK(d) {
// This disables a safety check intended to prevent DNSControl and
// another system getting into a battle as they both try to update
// the same record over and over, back and forth. However, people
// kept asking for it so... caveat emptor!
// It only affects the current domain.
d.unmanaged_disable_safety_check = true;
}
/**
* @deprecated
*/

View File

@@ -86,7 +86,7 @@ func TestParsedFiles(t *testing.T) {
as := string(actualJSON)
_, _ = es, as
// When debugging, leave behind the actual result:
// os.WriteFile(expectedFile+".ACTUAL", []byte(es), 0644)
//os.WriteFile(expectedFile+".ACTUAL", []byte(as), 0644)
testifyrequire.JSONEqf(t, es, as, "EXPECTING %q = \n```\n%s\n```", expectedFile, as)
// For each domain, if there is a zone file, test against it:

View File

@@ -1,8 +1,12 @@
{
"registrars": [],
"dns_providers": [],
"domains": [
{
"name": "foo.com",
"registrar": "none",
"dnsProviders": {},
"records": [],
"ignored_names": [
{
"pattern": "testignore",
@@ -39,10 +43,48 @@
"type": "CNAME"
}
],
"name": "foo.com",
"records": [],
"registrar": "none"
"unmanaged": [
{
"label_pattern": "testignore",
"rType_pattern": "*",
"target_pattern": "*"
},
{
"label_pattern": "testignore2",
"rType_pattern": "A",
"target_pattern": "*"
},
{
"label_pattern": "testignore3",
"rType_pattern": "A, CNAME, TXT",
"target_pattern": "*"
},
{
"label_pattern": "testignore4",
"rType_pattern": "*",
"target_pattern": "*"
},
{
"label_pattern": "*",
"rType_pattern": "CNAME",
"target_pattern": "testtarget"
},
{
"label_pattern": "legacyignore",
"rType_pattern": "*",
"target_pattern": "*"
},
{
"label_pattern": "@",
"rType_pattern": "*",
"target_pattern": "*"
},
{
"label_pattern": "*",
"rType_pattern": "CNAME",
"target_pattern": "@"
}
]
}
],
"registrars": []
}
]
}

View File

@@ -12,7 +12,14 @@
"pattern": "\\*.testignore",
"types": "*"
}
],
"unmanaged": [
{
"label_pattern": "\\*.testignore",
"rType_pattern": "*",
"target_pattern": "*"
}
]
}
]
}
}

View File

@@ -0,0 +1,6 @@
D("foo.com", "none"
, UNMANAGED("one")
, UNMANAGED("two", "A, CNAME")
, UNMANAGED("three", "TXT", "findme")
, UNMANAGED("notype", "", "targglob")
);

View File

@@ -0,0 +1,34 @@
{
"registrars": [],
"dns_providers": [],
"domains": [
{
"name": "foo.com",
"registrar": "none",
"dnsProviders": {},
"records": [],
"unmanaged": [
{
"label_pattern": "one",
"rType_pattern": "*",
"target_pattern": "*"
},
{
"label_pattern": "two",
"rType_pattern": "A, CNAME",
"target_pattern": "*"
},
{
"label_pattern": "three",
"rType_pattern": "TXT",
"target_pattern": "findme"
},
{
"label_pattern": "notype",
"rType_pattern": "*",
"target_pattern": "targglob"
}
]
}
]
}

View File

@@ -0,0 +1,5 @@
D("unsafe.com", "none"
, DISABLE_UNMANAGED_SAFETY_CHECK
);
D("safe.com", "none"
);

View File

@@ -0,0 +1,19 @@
{
"registrars": [],
"dns_providers": [],
"domains": [
{
"name": "unsafe.com",
"registrar": "none",
"dnsProviders": {},
"records": [],
"unmanaged_disable_safety_check": true
},
{
"name": "safe.com",
"registrar": "none",
"dnsProviders": {},
"records": []
}
]
}