From 83fd036828d6a144434489337cc26fec77424759 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 | 2 +- pkg/api/v1/conversion.go | 14 ++++++++++++-- pkg/api/v1/types.go | 2 +- pkg/api/v1beta1/types.go | 2 +- pkg/api/v1beta2/types.go | 2 +- pkg/api/v1beta3/conversion.go | 14 ++++++++++++-- pkg/api/v1beta3/types.go | 2 +- pkg/registry/pod/rest.go | 4 +++- 8 files changed, 32 insertions(+), 10 deletions(-) diff --git a/pkg/api/types.go b/pkg/api/types.go index 7328b459d28b0..87a87cf05fec1 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -1354,7 +1354,7 @@ type PodExecOptions struct { Container string // Command is the remote command to execute - Command string + 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 10573633b167f..60210a5eef8e1 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 cbde94d06b5af..983aa16177030 100644 --- a/pkg/api/v1/types.go +++ b/pkg/api/v1/types.go @@ -1340,7 +1340,7 @@ type PodExecOptions struct { 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 []string `json:"command" description:"the command to execute"` } // 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 35e550e0f9c9c..ac0f2c1b1a642 100644 --- a/pkg/api/v1beta1/types.go +++ b/pkg/api/v1beta1/types.go @@ -1208,7 +1208,7 @@ type PodExecOptions struct { 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 []string `json:"command" description:"the command to execute"` } // 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 50a849bbac840..864b4574bbd07 100644 --- a/pkg/api/v1beta2/types.go +++ b/pkg/api/v1beta2/types.go @@ -1228,7 +1228,7 @@ type PodExecOptions struct { 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 []string `json:"command" description:"the command to execute"` } // 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 b78c0b53ced50..c3ebf70fb152f 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 e5b9af7c759c7..5b8086265eff5 100644 --- a/pkg/api/v1beta3/types.go +++ b/pkg/api/v1beta3/types.go @@ -1340,7 +1340,7 @@ type PodExecOptions struct { 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 []string `json:"command" description:"the command to execute"` } // 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 cc5d795d4b1c5..4e2ec94e91c8f 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),