libnetwork: sandbox.rebuildDNS() move variables closer to where they're used
Some of these options required parsing the resolv.conf file, but the function could return an error further down; this patch moves the parsing closer to where their results are used (which may not happen if we're encountering an error before). Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
d178a71b7c
commit
806b4fbcad
1 changed files with 7 additions and 8 deletions
|
@ -368,19 +368,12 @@ func (sb *sandbox) rebuildDNS() error {
|
|||
if len(sb.extDNS) == 0 {
|
||||
sb.setExternalResolvers(currRC, resolvconf.IPv4, false)
|
||||
}
|
||||
var (
|
||||
dnsList = []string{sb.resolver.NameServer()}
|
||||
dnsOptionsList = resolvconf.GetOptions(currRC)
|
||||
dnsSearchList = resolvconf.GetSearchDomains(currRC)
|
||||
)
|
||||
|
||||
// external v6 DNS servers has to be listed in resolv.conf
|
||||
dnsList = append(dnsList, resolvconf.GetNameservers(currRC, resolvconf.IPv6)...)
|
||||
|
||||
// If the user config and embedded DNS server both have ndots option set,
|
||||
// remember the user's config so that unqualified names not in the docker
|
||||
// domain can be dropped.
|
||||
resOptions := sb.resolver.ResolverOptions()
|
||||
dnsOptionsList := resolvconf.GetOptions(currRC)
|
||||
|
||||
dnsOpt:
|
||||
for _, resOpt := range resOptions {
|
||||
|
@ -411,6 +404,12 @@ dnsOpt:
|
|||
dnsOptionsList = append(dnsOptionsList, resOptions...)
|
||||
}
|
||||
|
||||
var (
|
||||
// external v6 DNS servers have to be listed in resolv.conf
|
||||
dnsList = append([]string{sb.resolver.NameServer()}, resolvconf.GetNameservers(currRC, resolvconf.IPv6)...)
|
||||
dnsSearchList = resolvconf.GetSearchDomains(currRC)
|
||||
)
|
||||
|
||||
_, err = resolvconf.Build(sb.config.resolvConfPath, dnsList, dnsSearchList, dnsOptionsList)
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue