@@ -562,22 +562,35 @@ func FilterPodsForNodes(targetPodList core_v1.PodList, containerName string) map
562
562
563
563
for _ , pod := range targetPodList .Items {
564
564
565
- td := target {
566
- Name : pod .Name ,
567
- Namespace : pod .Namespace ,
568
- TargetContainer : containerName ,
569
- }
565
+ var containerNames []string
570
566
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 )
573
576
}
574
577
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 ,
578
584
}
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
+
581
594
}
582
595
}
583
596
return targets
0 commit comments