mirror of
https://github.com/coredns/coredns.git
synced 2025-08-07 06:47:01 +02:00
fix(plugin/secondary): make transfer property mandatory (#7249)
* fix(plugin/secondary): make transfer property mandatory Signed-off-by: wafuwafu13 <jaruwafu@gmail.com>
This commit is contained in:
parent
427b406300
commit
328165de1e
@ -72,6 +72,7 @@ func secondaryParse(c *caddy.Controller) (file.Zones, error) {
|
|||||||
names = append(names, origins[i])
|
names = append(names, origins[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasTransfer := false
|
||||||
for c.NextBlock() {
|
for c.NextBlock() {
|
||||||
var f []string
|
var f []string
|
||||||
|
|
||||||
@ -82,6 +83,7 @@ func secondaryParse(c *caddy.Controller) (file.Zones, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return file.Zones{}, err
|
return file.Zones{}, err
|
||||||
}
|
}
|
||||||
|
hasTransfer = true
|
||||||
default:
|
default:
|
||||||
return file.Zones{}, c.Errf("unknown property '%s'", c.Val())
|
return file.Zones{}, c.Errf("unknown property '%s'", c.Val())
|
||||||
}
|
}
|
||||||
@ -93,6 +95,9 @@ func secondaryParse(c *caddy.Controller) (file.Zones, error) {
|
|||||||
z[origin].Upstream = upstream.New()
|
z[origin].Upstream = upstream.New()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !hasTransfer {
|
||||||
|
return file.Zones{}, c.Err("secondary zones require a transfer from property")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return file.Zones{Z: z, Names: names}, nil
|
return file.Zones{Z: z, Names: names}, nil
|
||||||
|
@ -13,12 +13,6 @@ func TestSecondaryParse(t *testing.T) {
|
|||||||
transferFrom string
|
transferFrom string
|
||||||
zones []string
|
zones []string
|
||||||
}{
|
}{
|
||||||
{
|
|
||||||
`secondary`,
|
|
||||||
false, // TODO(miek): should actually be true, because without transfer lines this does not make sense
|
|
||||||
"",
|
|
||||||
nil,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
`secondary {
|
`secondary {
|
||||||
transfer from 127.0.0.1
|
transfer from 127.0.0.1
|
||||||
@ -35,6 +29,20 @@ func TestSecondaryParse(t *testing.T) {
|
|||||||
"127.0.0.1:53",
|
"127.0.0.1:53",
|
||||||
[]string{"example.org."},
|
[]string{"example.org."},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
`secondary`,
|
||||||
|
true,
|
||||||
|
"",
|
||||||
|
nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
`secondary example.org {
|
||||||
|
transferr from 127.0.0.1
|
||||||
|
}`,
|
||||||
|
true,
|
||||||
|
"",
|
||||||
|
nil,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
|
Loading…
Reference in New Issue
Block a user