diff --git a/pkg/api/types.go b/pkg/api/types.go index 7328b459d28..331181df362 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -1353,8 +1353,8 @@ type PodExecOptions struct { // Container in which to execute the command. Container string - // Command is the remote command to execute - Command string + // Command is the remote command to execute; argv array; not executed within a shell. + Command []string } // PodProxyOptions is the query options to a Pod's proxy call diff --git a/pkg/api/v1/conversion.go b/pkg/api/v1/conversion.go index 10573633b16..60210a5eef8 100644 --- a/pkg/api/v1/conversion.go +++ b/pkg/api/v1/conversion.go @@ -1715,7 +1715,12 @@ func init() { out.Stderr = in.Stderr out.TTY = in.TTY out.Container = in.Container - out.Command = in.Command + if in.Command != nil { + out.Command = make([]string, len(in.Command)) + for i := range in.Command { + out.Command[i] = in.Command[i] + } + } return nil }, func(in *newer.PodExecOptions, out *PodExecOptions, s conversion.Scope) error { @@ -1727,7 +1732,12 @@ func init() { out.Stderr = in.Stderr out.TTY = in.TTY out.Container = in.Container - out.Command = in.Command + if in.Command != nil { + out.Command = make([]string, len(in.Command)) + for i := range in.Command { + out.Command[i] = in.Command[i] + } + } return nil }, func(in *PodList, out *newer.PodList, s conversion.Scope) error { diff --git a/pkg/api/v1/types.go b/pkg/api/v1/types.go index cbde94d06b5..dafa218d7d0 100644 --- a/pkg/api/v1/types.go +++ b/pkg/api/v1/types.go @@ -1339,8 +1339,8 @@ type PodExecOptions struct { // Container in which to execute the command. Container string `json:"container,omitempty" description:"the container in which to execute the command. Defaults to only container if there is only one container in the pod."` - // Command is the remote command to execute - Command string `json:"command" description:"the command to execute"` + // Command is the remote command to execute; argv array; not executed within a shell. + Command []string `json:"command" description:"the command to execute; argv array; not executed within a shell"` } // PodProxyOptions is the query options to a Pod's proxy call diff --git a/pkg/api/v1beta1/types.go b/pkg/api/v1beta1/types.go index 35e550e0f9c..cec76c88b69 100644 --- a/pkg/api/v1beta1/types.go +++ b/pkg/api/v1beta1/types.go @@ -1207,8 +1207,8 @@ type PodExecOptions struct { // Container in which to execute the command. Container string `json:"container,omitempty" description:"the container in which to execute the command. Defaults to only container if there is only one container in the pod."` - // Command is the remote command to execute - Command string `json:"command" description:"the command to execute"` + // Command is the remote command to execute; argv array; not executed within a shell. + Command []string `json:"command" description:"the command to execute; argv array; not executed within a shell"` } // PodProxyOptions is the query options to a Pod's proxy call diff --git a/pkg/api/v1beta2/types.go b/pkg/api/v1beta2/types.go index 50a849bbac8..8d601d904ae 100644 --- a/pkg/api/v1beta2/types.go +++ b/pkg/api/v1beta2/types.go @@ -1227,8 +1227,8 @@ type PodExecOptions struct { // Container in which to execute the command. Container string `json:"container,omitempty" description:"the container in which to execute the command. Defaults to only container if there is only one container in the pod."` - // Command is the remote command to execute - Command string `json:"command" description:"the command to execute"` + // Command is the remote command to execute; argv array; not executed within a shell. + Command []string `json:"command" description:"the command to execute; argv array; not executed within a shell"` } // PodProxyOptions is the query options to a Pod's proxy call diff --git a/pkg/api/v1beta3/conversion.go b/pkg/api/v1beta3/conversion.go index b78c0b53ced..c3ebf70fb15 100644 --- a/pkg/api/v1beta3/conversion.go +++ b/pkg/api/v1beta3/conversion.go @@ -1850,7 +1850,12 @@ func convert_v1beta3_PodExecOptions_To_api_PodExecOptions(in *PodExecOptions, ou out.Stderr = in.Stderr out.TTY = in.TTY out.Container = in.Container - out.Command = in.Command + if in.Command != nil { + out.Command = make([]string, len(in.Command)) + for i := range in.Command { + out.Command[i] = in.Command[i] + } + } return nil } @@ -1863,7 +1868,12 @@ func convert_api_PodExecOptions_To_v1beta3_PodExecOptions(in *newer.PodExecOptio out.Stderr = in.Stderr out.TTY = in.TTY out.Container = in.Container - out.Command = in.Command + if in.Command != nil { + out.Command = make([]string, len(in.Command)) + for i := range in.Command { + out.Command[i] = in.Command[i] + } + } return nil } diff --git a/pkg/api/v1beta3/types.go b/pkg/api/v1beta3/types.go index e5b9af7c759..4be4746ab73 100644 --- a/pkg/api/v1beta3/types.go +++ b/pkg/api/v1beta3/types.go @@ -1339,8 +1339,8 @@ type PodExecOptions struct { // Container in which to execute the command. Container string `json:"container,omitempty" description:"the container in which to execute the command. Defaults to only container if there is only one container in the pod."` - // Command is the remote command to execute - Command string `json:"command" description:"the command to execute"` + // Command is the remote command to execute; argv array; not executed within a shell. + Command []string `json:"command" description:"the command to execute; argv array; not executed within a shell"` } // PodProxyOptions is the query options to a Pod's proxy call diff --git a/pkg/registry/pod/rest.go b/pkg/registry/pod/rest.go index cc5d795d4b1..4e2ec94e91c 100644 --- a/pkg/registry/pod/rest.go +++ b/pkg/registry/pod/rest.go @@ -261,7 +261,9 @@ func ExecLocation(getter ResourceGetter, connInfo client.ConnectionInfoGetter, c if opts.TTY { params.Add(api.ExecTTYParam, "1") } - params.Add("command", opts.Command) + for _, c := range opts.Command { + params.Add("command", c) + } loc := &url.URL{ Scheme: nodeScheme, Host: fmt.Sprintf("%s:%d", nodeHost, nodePort),