MCPcopy
hub / github.com/docker/compose / Port

Method Port

pkg/compose/port.go:29–41  ·  view source on GitHub ↗
(ctx context.Context, projectName string, service string, port uint16, options api.PortOptions)

Source from the content-addressed store, hash-verified

27)
28
29func (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
43func portNotFoundError(protocol string, port uint16, ctr container.Summary) error {
44 formatPort := func(protocol string, port uint16) string {

Callers

nothing calls this directly

Calls 3

getSpecifiedContainerMethod · 0.95
portNotFoundErrorFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected