aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris O'Haver <cohaver@infoblox.com> 2019-06-01 03:40:12 -0400
committerGravatar Miek Gieben <miek@miek.nl> 2019-06-01 08:40:12 +0100
commite1d0b63e3fade23864b0937300d637f6fa8bc56b (patch)
treeaef7c24b7e8466c19baba2dbe7f1ebe0b58b9f17
parent3b3fb6f5835a673f96c458b14104165dec2fb9f2 (diff)
downloadcoredns-e1d0b63e3fade23864b0937300d637f6fa8bc56b.tar.gz
coredns-e1d0b63e3fade23864b0937300d637f6fa8bc56b.tar.zst
coredns-e1d0b63e3fade23864b0937300d637f6fa8bc56b.zip
allow an empty response (#2855)
-rw-r--r--plugin/template/setup.go4
-rw-r--r--plugin/template/setup_test.go14
2 files changed, 7 insertions, 11 deletions
diff --git a/plugin/template/setup.go b/plugin/template/setup.go
index 9f122277a..33eeb086f 100644
--- a/plugin/template/setup.go
+++ b/plugin/template/setup.go
@@ -155,10 +155,6 @@ func templateParse(c *caddy.Controller) (handler Handler, err error) {
t.regex = append(t.regex, regexp.MustCompile(".*"))
}
- if len(t.answer) == 0 && len(t.authority) == 0 && t.rcode == dns.RcodeSuccess {
- return handler, c.Errf("no answer section for template found: %v", handler)
- }
-
handler.Templates = append(handler.Templates, t)
}
diff --git a/plugin/template/setup_test.go b/plugin/template/setup_test.go
index 64afac32a..f0eb33be1 100644
--- a/plugin/template/setup_test.go
+++ b/plugin/template/setup_test.go
@@ -36,13 +36,6 @@ func TestSetupParse(t *testing.T) {
{`template X`, true},
{`template ANY`, true},
{`template ANY X`, true},
- {`template ANY ANY (?P<x>`, true},
- {
- `template ANY ANY {
-
- }`,
- true,
- },
{
`template ANY ANY .* {
notavailable
@@ -92,6 +85,13 @@ func TestSetupParse(t *testing.T) {
true,
},
// examples
+ {`template ANY ANY (?P<x>`, false},
+ {
+ `template ANY ANY {
+
+ }`,
+ false,
+ },
{
`template ANY A example.com {
match ip-(?P<a>[0-9]*)-(?P<b>[0-9]*)-(?P<c>[0-9]*)-(?P<d>[0-9]*)[.]example[.]com