| 41 | } |
| 42 | |
| 43 | func portNotFoundError(protocol string, port uint16, ctr container.Summary) error { |
| 44 | formatPort := func(protocol string, port uint16) string { |
| 45 | return fmt.Sprintf("%d/%s", port, protocol) |
| 46 | } |
| 47 | |
| 48 | var containerPorts []string |
| 49 | for _, p := range ctr.Ports { |
| 50 | containerPorts = append(containerPorts, formatPort(p.Type, p.PrivatePort)) |
| 51 | } |
| 52 | |
| 53 | name := strings.TrimPrefix(ctr.Names[0], "/") |
| 54 | return fmt.Errorf("no port %s for container %s: %s", formatPort(protocol, port), name, strings.Join(containerPorts, ", ")) |
| 55 | } |