mirror of https://github.com/k3s-io/k3s
Merge pull request #10654 from nikhiljindal/getToPostClient
Updating kubectl to use POST instead of GET for port-forward and execpull/6/head
commit
d5ae8192fc
|
@ -169,7 +169,7 @@ func RunExec(f *cmdutil.Factory, cmd *cobra.Command, cmdIn io.Reader, cmdOut, cm
|
|||
return err
|
||||
}
|
||||
|
||||
req := client.RESTClient.Get().
|
||||
req := client.RESTClient.Post().
|
||||
Resource("pods").
|
||||
Name(pod.Name).
|
||||
Namespace(namespace).
|
||||
|
|
|
@ -27,6 +27,7 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||
)
|
||||
|
||||
|
@ -116,38 +117,24 @@ func TestPodAndContainer(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestExec(t *testing.T) {
|
||||
version := testapi.Version()
|
||||
tests := []struct {
|
||||
name, version, podPath, execPath, container string
|
||||
pod *api.Pod
|
||||
execErr bool
|
||||
}{
|
||||
{
|
||||
name: "v1beta3 - pod exec",
|
||||
version: "v1beta3",
|
||||
podPath: "/api/v1beta3/namespaces/test/pods/foo",
|
||||
execPath: "/api/v1beta3/namespaces/test/pods/foo/exec",
|
||||
name: "pod exec",
|
||||
version: version,
|
||||
podPath: "/api/" + version + "/namespaces/test/pods/foo",
|
||||
execPath: "/api/" + version + "/namespaces/test/pods/foo/exec",
|
||||
pod: execPod(),
|
||||
},
|
||||
{
|
||||
name: "v1beta3 - pod exec error",
|
||||
version: "v1beta3",
|
||||
podPath: "/api/v1beta3/namespaces/test/pods/foo",
|
||||
execPath: "/api/v1beta3/namespaces/test/pods/foo/exec",
|
||||
pod: execPod(),
|
||||
execErr: true,
|
||||
},
|
||||
{
|
||||
name: "v1 - pod exec",
|
||||
version: "v1",
|
||||
podPath: "/api/v1/namespaces/test/pods/foo",
|
||||
execPath: "/api/v1/namespaces/test/pods/foo/exec",
|
||||
pod: execPod(),
|
||||
},
|
||||
{
|
||||
name: "v1 - pod exec error",
|
||||
version: "v1",
|
||||
podPath: "/api/v1/namespaces/test/pods/foo",
|
||||
execPath: "/api/v1/namespaces/test/pods/foo/exec",
|
||||
name: "pod exec error",
|
||||
version: version,
|
||||
podPath: "/api/" + version + "/namespaces/test/pods/foo",
|
||||
execPath: "/api/" + version + "/namespaces/test/pods/foo/exec",
|
||||
pod: execPod(),
|
||||
execErr: true,
|
||||
},
|
||||
|
|
|
@ -117,7 +117,7 @@ func RunPortForward(f *cmdutil.Factory, cmd *cobra.Command, args []string, fw po
|
|||
close(stopCh)
|
||||
}()
|
||||
|
||||
req := client.RESTClient.Get().
|
||||
req := client.RESTClient.Post().
|
||||
Resource("pods").
|
||||
Namespace(namespace).
|
||||
Name(pod.Name).
|
||||
|
|
|
@ -24,6 +24,7 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||
)
|
||||
|
||||
|
@ -38,6 +39,7 @@ func (f *fakePortForwarder) ForwardPorts(req *client.Request, config *client.Con
|
|||
}
|
||||
|
||||
func TestPortForward(t *testing.T) {
|
||||
version := testapi.Version()
|
||||
|
||||
tests := []struct {
|
||||
name, version, podPath, pfPath, container string
|
||||
|
@ -45,32 +47,17 @@ func TestPortForward(t *testing.T) {
|
|||
pfErr bool
|
||||
}{
|
||||
{
|
||||
name: "v1beta3 - pod portforward",
|
||||
version: "v1beta3",
|
||||
podPath: "/api/v1beta3/namespaces/test/pods/foo",
|
||||
pfPath: "/api/v1beta3/namespaces/test/pods/foo/portforward",
|
||||
name: "pod portforward",
|
||||
version: version,
|
||||
podPath: "/api/" + version + "/namespaces/test/pods/foo",
|
||||
pfPath: "/api/" + version + "/namespaces/test/pods/foo/portforward",
|
||||
pod: execPod(),
|
||||
},
|
||||
{
|
||||
name: "v1beta3 - pod portforward error",
|
||||
version: "v1beta3",
|
||||
podPath: "/api/v1beta3/namespaces/test/pods/foo",
|
||||
pfPath: "/api/v1beta3/namespaces/test/pods/foo/portforward",
|
||||
pod: execPod(),
|
||||
pfErr: true,
|
||||
},
|
||||
{
|
||||
name: "v1 - pod portforward",
|
||||
version: "v1",
|
||||
podPath: "/api/v1/namespaces/test/pods/foo",
|
||||
pfPath: "/api/v1/namespaces/test/pods/foo/portforward",
|
||||
pod: execPod(),
|
||||
},
|
||||
{
|
||||
name: "v1 - pod portforward error",
|
||||
version: "v1",
|
||||
podPath: "/api/v1/namespaces/test/pods/foo",
|
||||
pfPath: "/api/v1/namespaces/test/pods/foo/portforward",
|
||||
name: "pod portforward error",
|
||||
version: version,
|
||||
podPath: "/api/" + version + "/namespaces/test/pods/foo",
|
||||
pfPath: "/api/" + version + "/namespaces/test/pods/foo/portforward",
|
||||
pod: execPod(),
|
||||
pfErr: true,
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue