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

Function GetContainerName

pkg/containerutil/containerutil.go:621–637  ·  view source on GitHub ↗
(containerLabels map[string]string)

Source from the content-addressed store, hash-verified

619}
620
621func GetContainerName(containerLabels map[string]string) string {
622 if name, ok := containerLabels[labels.Name]; ok {
623 return name
624 }
625
626 if ns, ok := containerLabels[k8slabels.PodNamespace]; ok {
627 if podName, ok := containerLabels[k8slabels.PodName]; ok {
628 if containerName, ok := containerLabels[k8slabels.ContainerName]; ok {
629 // Container
630 return fmt.Sprintf("k8s://%s/%s/%s", ns, podName, containerName)
631 }
632 // Pod sandbox
633 return fmt.Sprintf("k8s://%s/%s", ns, podName)
634 }
635 }
636 return ""
637}
638
639// EncodeContainerRmOptLabel encodes bool value for the --rm option into string value for a label.
640func EncodeContainerRmOptLabel(rmOpt bool) string {

Callers 5

PreProcessMethod · 0.92
matchesNameFilterMethod · 0.92
idOrNameFilterFunction · 0.92
StatsFunction · 0.92
prepareContainersFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…