(ctx context.Context, projectName string, service string, port uint16, options api.PortOptions)
| 27 | ) |
| 28 | |
| 29 | func (s *composeService) Port(ctx context.Context, projectName string, service string, port uint16, options api.PortOptions) (string, int, error) { |
| 30 | projectName = strings.ToLower(projectName) |
| 31 | ctr, err := s.getSpecifiedContainer(ctx, projectName, oneOffInclude, false, service, options.Index) |
| 32 | if err != nil { |
| 33 | return "", 0, err |
| 34 | } |
| 35 | for _, p := range ctr.Ports { |
| 36 | if p.PrivatePort == port && p.Type == options.Protocol { |
| 37 | return p.IP.String(), int(p.PublicPort), nil |
| 38 | } |
| 39 | } |
| 40 | return "", 0, portNotFoundError(options.Protocol, port, ctr) |
| 41 | } |
| 42 | |
| 43 | func portNotFoundError(protocol string, port uint16, ctr container.Summary) error { |
| 44 | formatPort := func(protocol string, port uint16) string { |
nothing calls this directly
no test coverage detected