Skip to content

Commit 7bec239

Browse files
enable ALL for TARGET_CONTAINER
Signed-off-by: MichaelMorris <[email protected]>
1 parent 5554a29 commit 7bec239

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

pkg/utils/common/pods.go

+25-12
Original file line numberDiff line numberDiff line change
@@ -562,22 +562,35 @@ func FilterPodsForNodes(targetPodList core_v1.PodList, containerName string) map
562562

563563
for _, pod := range targetPodList.Items {
564564

565-
td := target{
566-
Name: pod.Name,
567-
Namespace: pod.Namespace,
568-
TargetContainer: containerName,
569-
}
565+
var containerNames []string
570566

571-
if td.TargetContainer == "" {
572-
td.TargetContainer = pod.Spec.Containers[0].Name
567+
switch containerName {
568+
case "ALL":
569+
for _, container := range pod.Spec.Containers {
570+
containerNames = append(containerNames, container.Name)
571+
}
572+
case "":
573+
containerNames = append(containerNames, pod.Spec.Containers[0].Name)
574+
default:
575+
containerNames = append(containerNames, containerName)
573576
}
574577

575-
if targets[pod.Spec.NodeName] == nil {
576-
targets[pod.Spec.NodeName] = &TargetsDetails{
577-
Target: []target{td},
578+
for _, targetName := range containerNames {
579+
580+
td := target{
581+
Name: pod.Name,
582+
Namespace: pod.Namespace,
583+
TargetContainer: targetName,
578584
}
579-
} else {
580-
targets[pod.Spec.NodeName].Target = append(targets[pod.Spec.NodeName].Target, td)
585+
586+
if targets[pod.Spec.NodeName] == nil {
587+
targets[pod.Spec.NodeName] = &TargetsDetails{
588+
Target: []target{td},
589+
}
590+
} else {
591+
targets[pod.Spec.NodeName].Target = append(targets[pod.Spec.NodeName].Target, td)
592+
}
593+
581594
}
582595
}
583596
return targets

0 commit comments

Comments
 (0)