mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
libnetwork/resolvconf: Build: decorate error for invalid nameservers
Using the same prefix as is used in `Sandbox.loadResolvConf`, but omiting
the value, as it's already part of the error message;
829b695375/libnetwork/sandbox_dns_unix.go (L258-L261)
Unfortunately, `netip.ParseAddr` returns a non-exported (`parseAddrError`)
error-type; https://cs.opensource.google/go/go/+/refs/tags/go1.24.3:src/net/netip/netip.go;l=115
So we don't have the option to omit the `` from the error-message, and to
take the underlying `msg` field;
https://cs.opensource.google/go/go/+/refs/tags/go1.24.3:src/net/netip/netip.go;l=141-153
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -3,6 +3,7 @@ package resolvconf
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"net/netip"
|
||||
"os"
|
||||
|
||||
@@ -130,7 +131,7 @@ func Build(path string, nameservers, dnsSearch, dnsOptions []string) (*File, err
|
||||
for _, addr := range nameservers {
|
||||
ipAddr, err := netip.ParseAddr(addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("bad nameserver address: %w", err)
|
||||
}
|
||||
ns = append(ns, ipAddr)
|
||||
}
|
||||
|
||||
@@ -349,7 +349,7 @@ search search1
|
||||
{
|
||||
doc: "invalid nameserver",
|
||||
nameServers: []string{"resolver.example.com"},
|
||||
expErr: `ParseAddr("resolver.example.com"): unexpected character (at "resolver.example.com")`,
|
||||
expErr: `bad nameserver address: ParseAddr("resolver.example.com"): unexpected character (at "resolver.example.com")`,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user