Do Itoa once so line items are simpler

This commit is contained in:
Chris Bednarski 2015-11-17 16:31:47 -08:00
parent 3b7c252090
commit 43aaf94383

View file

@ -272,14 +272,15 @@ func (d *DockerDriver) createContainer(ctx *ExecContext, task *structs.Task, dri
exposedPorts := map[docker.Port]struct{}{} exposedPorts := map[docker.Port]struct{}{}
for _, port := range network.ReservedPorts { for _, port := range network.ReservedPorts {
portStr := docker.Port(port.Value) hostPortStr := strconv.Itoa(port.Value)
dockerPort := docker.Port(hostPortStr)
publishedPorts[portStr+"/tcp"] = []docker.PortBinding{docker.PortBinding{HostIP: network.IP, HostPort: strconv.Itoa(port.Value)}} publishedPorts[dockerPort+"/tcp"] = []docker.PortBinding{docker.PortBinding{HostIP: network.IP, HostPort: hostPortStr}}
publishedPorts[portStr+"/udp"] = []docker.PortBinding{docker.PortBinding{HostIP: network.IP, HostPort: strconv.Itoa(port.Value)}} publishedPorts[dockerPort+"/udp"] = []docker.PortBinding{docker.PortBinding{HostIP: network.IP, HostPort: hostPortStr}}
d.logger.Printf("[DEBUG] driver.docker: allocated port %s:%d -> %d (static)\n", network.IP, port.Value, port.Value) d.logger.Printf("[DEBUG] driver.docker: allocated port %s:%d -> %d (static)\n", network.IP, port.Value, port.Value)
exposedPorts[portStr+"/tcp"] = struct{}{} exposedPorts[dockerPort+"/tcp"] = struct{}{}
exposedPorts[portStr+"/udp"] = struct{}{} exposedPorts[dockerPort+"/udp"] = struct{}{}
d.logger.Printf("[DEBUG] driver.docker: exposed port %d\n", port.Value) d.logger.Printf("[DEBUG] driver.docker: exposed port %d\n", port.Value)
} }