(containerLabels map[string]string)
| 619 | } |
| 620 | |
| 621 | func 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. |
| 640 | func EncodeContainerRmOptLabel(rmOpt bool) string { |
no outgoing calls
no test coverage detected
searching dependent graphs…