aboutsummaryrefslogtreecommitdiff
path: root/plugin/file
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2019-07-27 11:47:55 +0000
committerGravatar GitHub <noreply@github.com> 2019-07-27 11:47:55 +0000
commit7a3371d740065d4a0e321abe27fe090300a4ce4f (patch)
treef6a6a0cd8e54ea88c9af25ab5147d0abf86d0fc4 /plugin/file
parentcfc4948f92f44a09a15117f0120a8dcf97e61053 (diff)
downloadcoredns-7a3371d740065d4a0e321abe27fe090300a4ce4f.tar.gz
coredns-7a3371d740065d4a0e321abe27fe090300a4ce4f.tar.zst
coredns-7a3371d740065d4a0e321abe27fe090300a4ce4f.zip
plugin/file: allow README.md testing (#3052)
* Fix corefile usage * plugin/file: allow README.md testing Allow readme testing for the file plugin and fix bugs that where found: * the reader wasn't reset when re-reading the same io.reader for a different origin. Signed-off-by: Miek Gieben <miek@miek.nl> * Update test/example_test.go Co-Authored-By: Michael Grosser <development@stp-ip.net>
Diffstat (limited to 'plugin/file')
-rw-r--r--plugin/file/README.md10
-rw-r--r--plugin/file/file.go2
-rw-r--r--plugin/file/setup.go1
3 files changed, 7 insertions, 6 deletions
diff --git a/plugin/file/README.md b/plugin/file/README.md
index 5322a8ac6..58cfe9586 100644
--- a/plugin/file/README.md
+++ b/plugin/file/README.md
@@ -44,7 +44,7 @@ file DBFILE [ZONES... ] {
Load the `example.org` zone from `example.org.signed` and allow transfers to the internet, but send
notifies to 10.240.1.1
-~~~ txt
+~~~ corefile
example.org {
file example.org.signed {
transfer to *
@@ -55,7 +55,7 @@ example.org {
Or use a single zone file for multiple zones:
-~~~ txt
+~~~ corefile
. {
file example.org.signed example.org example.net {
transfer to *
@@ -67,7 +67,7 @@ Or use a single zone file for multiple zones:
Note that if you have a configuration like the following you may run into a problem of the origin
not being correctly recognized:
-~~~ txt
+~~~ corefile
. {
file db.example.org
}
@@ -78,7 +78,7 @@ which, in this case, is the root zone. Any contents of `db.example.org` will the
origin set; this may or may not do what you want.
It's better to be explicit here and specify the correct origin. This can be done in two ways:
-~~~ txt
+~~~ corefile
. {
file db.example.org example.org
}
@@ -86,7 +86,7 @@ It's better to be explicit here and specify the correct origin. This can be done
Or
-~~~ txt
+~~~ corefile
example.org {
file db.example.org
}
diff --git a/plugin/file/file.go b/plugin/file/file.go
index 169720e64..c63fa43f5 100644
--- a/plugin/file/file.go
+++ b/plugin/file/file.go
@@ -145,7 +145,7 @@ func Parse(f io.Reader, origin, fileName string, serial int64) (*Zone, error) {
}
}
if !seenSOA {
- return nil, fmt.Errorf("file %q has no SOA record", fileName)
+ return nil, fmt.Errorf("file %q has no SOA record for origin %s", fileName, origin)
}
return z, nil
diff --git a/plugin/file/setup.go b/plugin/file/setup.go
index 162db6d65..ce78e815e 100644
--- a/plugin/file/setup.go
+++ b/plugin/file/setup.go
@@ -87,6 +87,7 @@ func fileParse(c *caddy.Controller) (Zones, error) {
origins[i] = plugin.Host(origins[i]).Normalize()
z[origins[i]] = NewZone(origins[i], fileName)
if openErr == nil {
+ reader.Seek(0, 0)
zone, err := Parse(reader, origins[i], fileName, 0)
if err == nil {
z[origins[i]] = zone