@@ -503,12 +503,21 @@ func RandomSuffix() string {
503
503
}
504
504
505
505
// LookForStringInPodExec looks for the given string in the output of a command
506
- // executed in a specific pod container.
506
+ // executed in the first container of specified pod .
507
507
// TODO(alejandrox1): move to pod/ subpkg once kubectl methods are refactored.
508
508
func LookForStringInPodExec (ns , podName string , command []string , expectedString string , timeout time.Duration ) (result string , err error ) {
509
+ return LookForStringInPodExecToContainer (ns , podName , "" , command , expectedString , timeout )
510
+ }
511
+
512
+ // LookForStringInPodExecToContainer looks for the given string in the output of a
513
+ // command executed in specified pod container, or first container if not specified.
514
+ func LookForStringInPodExecToContainer (ns , podName , containerName string , command []string , expectedString string , timeout time.Duration ) (result string , err error ) {
509
515
return lookForString (expectedString , timeout , func () string {
510
- // use the first container
511
- args := []string {"exec" , podName , fmt .Sprintf ("--namespace=%v" , ns ), "--" }
516
+ args := []string {"exec" , podName , fmt .Sprintf ("--namespace=%v" , ns )}
517
+ if len (containerName ) > 0 {
518
+ args = append (args , fmt .Sprintf ("--container=%s" , containerName ))
519
+ }
520
+ args = append (args , "--" )
512
521
args = append (args , command ... )
513
522
return RunKubectlOrDie (ns , args ... )
514
523
})
0 commit comments