plugins: calling Dispenser itself is a mistake (#3323)

Remove all these uses and just make them work on caddy.Controller. Also
don't export parsing functions as their should be private to the plugin.

Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
Miek Gieben 2019-09-28 10:41:12 +01:00 committed by GitHub
parent ba5d4a6372
commit 03a3695ea9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 13 deletions

View file

@ -13,7 +13,6 @@ import (
"github.com/coredns/coredns/plugin/pkg/transport"
"github.com/caddyserver/caddy"
"github.com/caddyserver/caddy/caddyfile"
)
func init() { plugin.Register("forward", setup) }
@ -74,7 +73,7 @@ func parseForward(c *caddy.Controller) (*Forward, error) {
return nil, plugin.ErrOnce
}
i++
f, err = ParseForwardStanza(&c.Dispenser)
f, err = parseStanza(c)
if err != nil {
return nil, err
}
@ -82,8 +81,7 @@ func parseForward(c *caddy.Controller) (*Forward, error) {
return f, nil
}
// ParseForwardStanza parses one forward stanza
func ParseForwardStanza(c *caddyfile.Dispenser) (*Forward, error) {
func parseStanza(c *caddy.Controller) (*Forward, error) {
f := New()
if !c.Args(&f.from) {
@ -128,7 +126,7 @@ func ParseForwardStanza(c *caddyfile.Dispenser) (*Forward, error) {
return f, nil
}
func parseBlock(c *caddyfile.Dispenser, f *Forward) error {
func parseBlock(c *caddy.Controller, f *Forward) error {
switch c.Val() {
case "except":
ignore := c.RemainingArgs()