Clean up extraneous variables

This commit is contained in:
Chris Bednarski 2015-11-17 14:51:38 -08:00
parent f2e8357e4a
commit 629cdd6baa
1 changed files with 5 additions and 7 deletions

View File

@ -224,9 +224,8 @@ func (d *DockerDriver) createContainer(ctx *ExecContext, task *structs.Task, dri
hostConfig.Privileged = hostPrivileged hostConfig.Privileged = hostPrivileged
// set DNS servers // set DNS servers
dns := driverConfig.DNS if driverConfig.DNS != "" {
if dns != "" { for _, v := range strings.Split(driverConfig.DNS, ",") {
for _, v := range strings.Split(dns, ",") {
ip := strings.TrimSpace(v) ip := strings.TrimSpace(v)
if net.ParseIP(ip) != nil { if net.ParseIP(ip) != nil {
hostConfig.DNS = append(hostConfig.DNS, ip) hostConfig.DNS = append(hostConfig.DNS, ip)
@ -237,9 +236,8 @@ func (d *DockerDriver) createContainer(ctx *ExecContext, task *structs.Task, dri
} }
// set DNS search domains // set DNS search domains
dnsSearch := driverConfig.SearchDomains if driverConfig.SearchDomains != "" {
if dnsSearch != "" { for _, v := range strings.Split(driverConfig.SearchDomains, ",") {
for _, v := range strings.Split(dnsSearch, ",") {
hostConfig.DNSSearch = append(hostConfig.DNSSearch, strings.TrimSpace(v)) hostConfig.DNSSearch = append(hostConfig.DNSSearch, strings.TrimSpace(v))
} }
} }
@ -265,7 +263,7 @@ func (d *DockerDriver) createContainer(ctx *ExecContext, task *structs.Task, dri
if len(task.Resources.Networks) == 0 { if len(task.Resources.Networks) == 0 {
d.logger.Print("[INFO] driver.docker: No network interfaces are available") d.logger.Print("[INFO] driver.docker: No network interfaces are available")
if len(driverConfig.PortMap[0]) > 0 { if len(driverConfig.PortMap[0]) > 0 {
return nil, fmt.Errorf("Trying to map ports but no network interface is available") return c, fmt.Errorf("Trying to map ports but no network interface is available")
} }
} else { } else {
// TODO add support for more than one network // TODO add support for more than one network