Add container flag where is required to run the command

This commit is contained in:
Manuel de Brito Fontes 2018-01-23 17:09:41 -03:00 committed by Manuel Alejandro de Brito Fontes
parent 12c8ea721d
commit 1ec0a60746
2 changed files with 25 additions and 10 deletions

View file

@ -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