daemon: inline Daemon.getDNSSearchSettings
This function was created as a "method", but didn't use the Daemon in any way, and all other options were checked inline, so let's not pretend this function is more "special" than the other checks, and inline the code. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
603547fa19
commit
2cbed9d2a8
2 changed files with 14 additions and 18 deletions
|
@ -28,18 +28,6 @@ import (
|
|||
"github.com/docker/go-connections/nat"
|
||||
)
|
||||
|
||||
func (daemon *Daemon) getDNSSearchSettings(cfg *config.Config, container *container.Container) []string {
|
||||
if len(container.HostConfig.DNSSearch) > 0 {
|
||||
return container.HostConfig.DNSSearch
|
||||
}
|
||||
|
||||
if len(cfg.DNSSearch) > 0 {
|
||||
return cfg.DNSSearch
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (daemon *Daemon) buildSandboxOptions(cfg *config.Config, container *container.Container) ([]libnetwork.SandboxOption, error) {
|
||||
var (
|
||||
sboxOptions []libnetwork.SandboxOption
|
||||
|
@ -77,8 +65,12 @@ func (daemon *Daemon) buildSandboxOptions(cfg *config.Config, container *contain
|
|||
sboxOptions = append(sboxOptions, libnetwork.OptionDNS(d))
|
||||
}
|
||||
|
||||
dnsSearch := daemon.getDNSSearchSettings(cfg, container)
|
||||
|
||||
var dnsSearch []string
|
||||
if len(container.HostConfig.DNSSearch) > 0 {
|
||||
dnsSearch = container.HostConfig.DNSSearch
|
||||
} else if len(cfg.DNSSearch) > 0 {
|
||||
dnsSearch = cfg.DNSSearch
|
||||
}
|
||||
for _, ds := range dnsSearch {
|
||||
sboxOptions = append(sboxOptions, libnetwork.OptionDNSSearch(ds))
|
||||
}
|
||||
|
|
|
@ -112,8 +112,7 @@ func (daemon *Daemon) createSpec(ctx context.Context, daemonCfg *configStore, c
|
|||
mounts = append(mounts, secretMounts...)
|
||||
}
|
||||
|
||||
configMounts := c.ConfigMounts()
|
||||
if configMounts != nil {
|
||||
if configMounts := c.ConfigMounts(); configMounts != nil {
|
||||
mounts = append(mounts, configMounts...)
|
||||
}
|
||||
|
||||
|
@ -145,8 +144,6 @@ func (daemon *Daemon) createSpec(ctx context.Context, daemonCfg *configStore, c
|
|||
return nil, errors.Wrapf(err, "container %s", c.ID)
|
||||
}
|
||||
|
||||
dnsSearch := daemon.getDNSSearchSettings(&daemonCfg.Config, c)
|
||||
|
||||
// Get endpoints for the libnetwork allocated networks to the container
|
||||
var epList []string
|
||||
AllowUnqualifiedDNSQuery := false
|
||||
|
@ -197,6 +194,13 @@ func (daemon *Daemon) createSpec(ctx context.Context, daemonCfg *configStore, c
|
|||
epList = append(epList, gwHNSID)
|
||||
}
|
||||
|
||||
var dnsSearch []string
|
||||
if len(c.HostConfig.DNSSearch) > 0 {
|
||||
dnsSearch = c.HostConfig.DNSSearch
|
||||
} else if len(daemonCfg.DNSSearch) > 0 {
|
||||
dnsSearch = daemonCfg.DNSSearch
|
||||
}
|
||||
|
||||
s.Windows.Network = &specs.WindowsNetwork{
|
||||
AllowUnqualifiedDNSQuery: AllowUnqualifiedDNSQuery,
|
||||
DNSSearchList: dnsSearch,
|
||||
|
|
Loading…
Add table
Reference in a new issue