Skip to content

Commit

Permalink
api/task: simplify code a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Nodir Turakulov authored and sparrc committed Apr 21, 2022
1 parent 5ece05b commit 51111de
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions agent/api/task/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -1929,12 +1929,7 @@ func (task *Task) dockerPortMap(container *apicontainer.Container) nat.PortMap {

for _, portBinding := range container.Ports {
dockerPort := nat.Port(strconv.Itoa(int(portBinding.ContainerPort)) + "/" + portBinding.Protocol.String())
currentMappings, existing := dockerPortMap[dockerPort]
if existing {
dockerPortMap[dockerPort] = append(currentMappings, nat.PortBinding{HostPort: strconv.Itoa(int(portBinding.HostPort))})
} else {
dockerPortMap[dockerPort] = []nat.PortBinding{{HostPort: strconv.Itoa(int(portBinding.HostPort))}}
}
dockerPortMap[dockerPort] = append(dockerPortMap[dockerPort], nat.PortBinding{HostPort: strconv.Itoa(int(portBinding.HostPort))})
}
return dockerPortMap
}
Expand Down

0 comments on commit 51111de

Please sign in to comment.