Skip to content

Commit

Permalink
enable ALL for TARGET_CONTAINER (#683)
Browse files Browse the repository at this point in the history
Signed-off-by: MichaelMorris <[email protected]>
  • Loading branch information
MichaelMorrisEst authored Mar 14, 2024
1 parent 6d26c21 commit b5a24b4
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions pkg/utils/common/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,22 +562,35 @@ func FilterPodsForNodes(targetPodList core_v1.PodList, containerName string) map

for _, pod := range targetPodList.Items {

td := target{
Name: pod.Name,
Namespace: pod.Namespace,
TargetContainer: containerName,
}
var containerNames []string

if td.TargetContainer == "" {
td.TargetContainer = pod.Spec.Containers[0].Name
switch containerName {
case "ALL":
for _, container := range pod.Spec.Containers {
containerNames = append(containerNames, container.Name)
}
case "":
containerNames = append(containerNames, pod.Spec.Containers[0].Name)
default:
containerNames = append(containerNames, containerName)
}

if targets[pod.Spec.NodeName] == nil {
targets[pod.Spec.NodeName] = &TargetsDetails{
Target: []target{td},
for _, targetName := range containerNames {

td := target{
Name: pod.Name,
Namespace: pod.Namespace,
TargetContainer: targetName,
}
} else {
targets[pod.Spec.NodeName].Target = append(targets[pod.Spec.NodeName].Target, td)

if targets[pod.Spec.NodeName] == nil {
targets[pod.Spec.NodeName] = &TargetsDetails{
Target: []target{td},
}
} else {
targets[pod.Spec.NodeName].Target = append(targets[pod.Spec.NodeName].Target, td)
}

}
}
return targets
Expand Down

0 comments on commit b5a24b4

Please sign in to comment.