diff options
author | 2021-12-23 18:02:28 +0100 | |
---|---|---|
committer | 2021-12-23 12:02:28 -0500 | |
commit | 74f3bea50f8ae83ae1aed85b6039572912138424 (patch) | |
tree | c27f81457c6c2a65a9e8e6a9f02d8c9aa9866720 | |
parent | b53aac992aa16a1449e341bf9b27b9dc600420e7 (diff) | |
download | coredns-74f3bea50f8ae83ae1aed85b6039572912138424.tar.gz coredns-74f3bea50f8ae83ae1aed85b6039572912138424.tar.zst coredns-74f3bea50f8ae83ae1aed85b6039572912138424.zip |
Convert HostPortOrFile error to var (#5058)
Convert "no nameservers found" error on parse.HostPortOrFile() to an
exported var for use with `errors.Is()`.
Signed-off-by: SuperQ <superq@gmail.com>
-rw-r--r-- | plugin/pkg/parse/host.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/plugin/pkg/parse/host.go b/plugin/pkg/parse/host.go index 67cfa86d8..3bee4f96e 100644 --- a/plugin/pkg/parse/host.go +++ b/plugin/pkg/parse/host.go @@ -1,6 +1,7 @@ package parse import ( + "errors" "fmt" "net" "os" @@ -11,6 +12,9 @@ import ( "github.com/miekg/dns" ) +// ErrNoNameservers is returned by HostPortOrFile if no servers can be parsed. +var ErrNoNameservers = errors.New("no nameservers found") + // Strips the zone, but preserves any port that comes after the zone func stripZone(host string) string { if strings.Contains(host, "%") { @@ -70,7 +74,7 @@ func HostPortOrFile(s ...string) ([]string, error) { servers = append(servers, h) } if len(servers) == 0 { - return servers, fmt.Errorf("no nameservers found") + return servers, ErrNoNameservers } return servers, nil } |