Add container flag where is required to run the command
This commit is contained in:
parent
12c8ea721d
commit
1ec0a60746
2 changed files with 25 additions and 10 deletions
|
|
@ -31,11 +31,12 @@ func (f *Framework) ExecCommand(pod *v1.Pod, command string) (string, error) {
|
|||
execErr bytes.Buffer
|
||||
)
|
||||
|
||||
args := fmt.Sprintf("kubectl exec --namespace %v %v -- %v", pod.Namespace, pod.Name, command)
|
||||
if len(pod.Spec.Containers) != 1 {
|
||||
return "", fmt.Errorf("could not determine which container to use")
|
||||
args = fmt.Sprintf("kubectl exec --namespace %v %v --container nginx-ingress-controller -- %v", pod.Namespace, pod.Name, command)
|
||||
}
|
||||
|
||||
args := fmt.Sprintf("kubectl exec -n %v %v -- %v", pod.Namespace, pod.Name, command)
|
||||
log("DEBUG", "Executing command \"%v\"", args)
|
||||
cmd := exec.Command("/bin/bash", "-c", args)
|
||||
cmd.Stdout = &execOut
|
||||
cmd.Stderr = &execErr
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue