(portMap network.PortMap)
| 649 | } |
| 650 | |
| 651 | func parsePortMap(portMap network.PortMap) ([]*api.PortConfig, error) { |
| 652 | exposedPorts := make([]*api.PortConfig, 0, len(portMap)) |
| 653 | |
| 654 | for port, mapping := range portMap { |
| 655 | var protocol api.PortConfig_Protocol |
| 656 | switch port.Proto() { |
| 657 | case network.TCP: |
| 658 | protocol = api.ProtocolTCP |
| 659 | case network.UDP: |
| 660 | protocol = api.ProtocolUDP |
| 661 | case network.SCTP: |
| 662 | protocol = api.ProtocolSCTP |
| 663 | default: |
| 664 | return nil, fmt.Errorf("invalid protocol: %s", port.Proto()) |
| 665 | } |
| 666 | |
| 667 | for _, binding := range mapping { |
| 668 | hostPort, err := strconv.ParseUint(binding.HostPort, 10, 16) |
| 669 | if err != nil { |
| 670 | return nil, err |
| 671 | } |
| 672 | |
| 673 | // TODO(aluzzardi): We're losing the port `name` here since |
| 674 | // there's no way to retrieve it back from the Engine. |
| 675 | exposedPorts = append(exposedPorts, &api.PortConfig{ |
| 676 | PublishMode: api.PublishModeHost, |
| 677 | Protocol: protocol, |
| 678 | TargetPort: uint32(port.Num()), |
| 679 | PublishedPort: uint32(hostPort), |
| 680 | }) |
| 681 | } |
| 682 | } |
| 683 | |
| 684 | return exposedPorts, nil |
| 685 | } |
| 686 | |
| 687 | type exitError struct { |
| 688 | code int |
no test coverage detected
searching dependent graphs…