mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
Add INCLUDE statement to include records from other domains (#1219)
This commit is contained in:
@ -103,6 +103,16 @@ function D(name, registrar) {
|
||||
conf.domain_names.push(name);
|
||||
}
|
||||
|
||||
function INCLUDE(name) {
|
||||
var domain = _getDomainObject(name);
|
||||
if (domain == null) {
|
||||
throw name + ' was not declared yet and therefore cannot be updated. Use D() before.';
|
||||
}
|
||||
return function(d) {
|
||||
d.records.push.apply(d.records, domain.obj.records);
|
||||
}
|
||||
}
|
||||
|
||||
// D_EXTEND(name): Update a DNS Domain already added with D(), or subdomain thereof
|
||||
function D_EXTEND(name) {
|
||||
var domain = _getDomainObject(name);
|
||||
|
12
pkg/js/parse_tests/039-include.js
Normal file
12
pkg/js/parse_tests/039-include.js
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
var REG = NewRegistrar("Third-Party","NONE");
|
||||
var CF = NewDnsProvider("Cloudflare", "CLOUDFLAREAPI");
|
||||
|
||||
D("foo.com!external",REG,DnsProvider(CF),
|
||||
A("@","1.2.3.4")
|
||||
);
|
||||
|
||||
D("foo.com!internal",REG,DnsProvider(CF),
|
||||
INCLUDE("foo.com!external"),
|
||||
A("local","127.0.0.1")
|
||||
);
|
49
pkg/js/parse_tests/039-include.json
Normal file
49
pkg/js/parse_tests/039-include.json
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"registrars": [
|
||||
{
|
||||
"name": "Third-Party",
|
||||
"type": "NONE"
|
||||
}
|
||||
],
|
||||
"dns_providers": [
|
||||
{
|
||||
"name": "Cloudflare",
|
||||
"type": "CLOUDFLAREAPI"
|
||||
}
|
||||
],
|
||||
"domains": [
|
||||
{
|
||||
"name": "foo.com!external",
|
||||
"registrar": "Third-Party",
|
||||
"dnsProviders": {
|
||||
"Cloudflare": -1
|
||||
},
|
||||
"records": [
|
||||
{
|
||||
"type": "A",
|
||||
"name": "@",
|
||||
"target": "1.2.3.4"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "foo.com!internal",
|
||||
"registrar": "Third-Party",
|
||||
"dnsProviders": {
|
||||
"Cloudflare": -1
|
||||
},
|
||||
"records": [
|
||||
{
|
||||
"type": "A",
|
||||
"name": "@",
|
||||
"target": "1.2.3.4"
|
||||
},
|
||||
{
|
||||
"type": "A",
|
||||
"name": "local",
|
||||
"target": "127.0.0.1"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user