From 283049f679bf943782747a91fb736bc2f141519e Mon Sep 17 00:00:00 2001 From: Cesar Wong Date: Mon, 4 May 2015 16:21:03 -0400 Subject: [PATCH] Fix pod exec options Change the command field to an array of strings. --- pkg/api/types.go | 4 ++-- pkg/api/v1/conversion.go | 14 ++++++++++++-- pkg/api/v1/types.go | 4 ++-- pkg/api/v1beta1/types.go | 4 ++-- pkg/api/v1beta2/types.go | 4 ++-- pkg/api/v1beta3/conversion.go | 14 ++++++++++++-- pkg/api/v1beta3/types.go | 4 ++-- pkg/registry/pod/rest.go | 4 +++- 8 files changed, 37 insertions(+), 15 deletions(-) diff --git a/pkg/api/types.go b/pkg/api/types.go index 7328b459d28b..331181df3620 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 10573633b167..60210a5eef8e 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 cbde94d06b5a..dafa218d7d09 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 35e550e0f9c9..cec76c88b69f 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 50a849bbac84..8d601d904ae1 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 b78c0b53ced5..c3ebf70fb152 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 e5b9af7c759c..4be4746ab737 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 cc5d795d4b1c..4e2ec94e91c8 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),