Commit fe9ba425 authored by Chris O'Haver's avatar Chris O'Haver Committed by GitHub

plugin/autopath: Don't panic on empty token (#5169)

* dont panic on empty token
Signed-off-by: default avatarChris O'Haver <cohaver@infoblox.com>
parent c5eb7d04
...@@ -2,6 +2,7 @@ package autopath ...@@ -2,6 +2,7 @@ package autopath
import ( import (
"fmt" "fmt"
"strings"
"github.com/coredns/caddy" "github.com/coredns/caddy"
"github.com/coredns/coredns/core/dnsserver" "github.com/coredns/coredns/core/dnsserver"
...@@ -50,7 +51,7 @@ func autoPathParse(c *caddy.Controller) (*AutoPath, string, error) { ...@@ -50,7 +51,7 @@ func autoPathParse(c *caddy.Controller) (*AutoPath, string, error) {
return ap, "", fmt.Errorf("no resolv-conf specified") return ap, "", fmt.Errorf("no resolv-conf specified")
} }
resolv := zoneAndresolv[len(zoneAndresolv)-1] resolv := zoneAndresolv[len(zoneAndresolv)-1]
if resolv[0] == '@' { if strings.HasPrefix(resolv, "@") {
mw = resolv[1:] mw = resolv[1:]
} else { } else {
// assume file on disk // assume file on disk
......
...@@ -33,6 +33,7 @@ func TestSetupAutoPath(t *testing.T) { ...@@ -33,6 +33,7 @@ func TestSetupAutoPath(t *testing.T) {
// negative // negative
{`autopath kubernetes`, true, "", "", nil, "open kubernetes: no such file or directory"}, {`autopath kubernetes`, true, "", "", nil, "open kubernetes: no such file or directory"},
{`autopath`, true, "", "", nil, "no resolv-conf"}, {`autopath`, true, "", "", nil, "no resolv-conf"},
{`autopath ""`, true, "", "", nil, "no such file"},
} }
for i, test := range tests { for i, test := range tests {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment