mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Return error instead of panic if container index outside bounds
Adds check for index out of bounds error instead of panic when passing container to kubectl exec. Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
This commit is contained in:
parent
3a0b683c01
commit
4e4d629af7
@ -1059,6 +1059,9 @@ func formatVolume(f *framework.Framework, pod *v1.Pod) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func podContainerExec(pod *v1.Pod, containerIndex int, command string) (string, error) {
|
func podContainerExec(pod *v1.Pod, containerIndex int, command string) (string, error) {
|
||||||
|
if containerIndex > len(pod.Spec.Containers)-1 {
|
||||||
|
return "", fmt.Errorf("container not found in pod: index %d", containerIndex)
|
||||||
|
}
|
||||||
var shell string
|
var shell string
|
||||||
var option string
|
var option string
|
||||||
if framework.NodeOSDistroIs("windows") {
|
if framework.NodeOSDistroIs("windows") {
|
||||||
|
Loading…
Reference in New Issue
Block a user