MCPcopy Create free account
hub / github.com/containerd/nerdctl / formatPublishers

Function formatPublishers

cmd/nerdctl/compose/compose_ps.go:348–363  ·  view source on GitHub ↗

formatPublishers parses and returns docker-compatible []PortPublisher from label map. If an error happens, an empty slice is returned.

(portMappings []cni.PortMapping)

Source from the content-addressed store, hash-verified

346// formatPublishers parses and returns docker-compatible []PortPublisher from
347// label map. If an error happens, an empty slice is returned.
348func formatPublishers(portMappings []cni.PortMapping) []PortPublisher {
349 mapper := func(pm cni.PortMapping) PortPublisher {
350 return PortPublisher{
351 URL: pm.HostIP,
352 TargetPort: int(pm.ContainerPort),
353 PublishedPort: int(pm.HostPort),
354 Protocol: pm.Protocol,
355 }
356 }
357
358 var dockerPorts []PortPublisher
359 for _, p := range portMappings {
360 dockerPorts = append(dockerPorts, mapper(p))
361 }
362 return dockerPorts
363}
364
365// statusForFilter returns the status value to be matched with the 'status' filter
366func statusForFilter(ctx context.Context, c containerd.Container) string {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…