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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
req := client.RESTClient.Get().
|
req := client.RESTClient.Post().
|
||||||
Resource("pods").
|
Resource("pods").
|
||||||
Name(pod.Name).
|
Name(pod.Name).
|
||||||
Namespace(namespace).
|
Namespace(namespace).
|
||||||
|
|
|
@ -27,6 +27,7 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -116,38 +117,24 @@ func TestPodAndContainer(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestExec(t *testing.T) {
|
func TestExec(t *testing.T) {
|
||||||
|
version := testapi.Version()
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name, version, podPath, execPath, container string
|
name, version, podPath, execPath, container string
|
||||||
pod *api.Pod
|
pod *api.Pod
|
||||||
execErr bool
|
execErr bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "v1beta3 - pod exec",
|
name: "pod exec",
|
||||||
version: "v1beta3",
|
version: version,
|
||||||
podPath: "/api/v1beta3/namespaces/test/pods/foo",
|
podPath: "/api/" + version + "/namespaces/test/pods/foo",
|
||||||
execPath: "/api/v1beta3/namespaces/test/pods/foo/exec",
|
execPath: "/api/" + version + "/namespaces/test/pods/foo/exec",
|
||||||
pod: execPod(),
|
pod: execPod(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "v1beta3 - pod exec error",
|
name: "pod exec error",
|
||||||
version: "v1beta3",
|
version: version,
|
||||||
podPath: "/api/v1beta3/namespaces/test/pods/foo",
|
podPath: "/api/" + version + "/namespaces/test/pods/foo",
|
||||||
execPath: "/api/v1beta3/namespaces/test/pods/foo/exec",
|
execPath: "/api/" + version + "/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",
|
|
||||||
pod: execPod(),
|
pod: execPod(),
|
||||||
execErr: true,
|
execErr: true,
|
||||||
},
|
},
|
||||||
|
|
|
@ -117,7 +117,7 @@ func RunPortForward(f *cmdutil.Factory, cmd *cobra.Command, args []string, fw po
|
||||||
close(stopCh)
|
close(stopCh)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req := client.RESTClient.Get().
|
req := client.RESTClient.Post().
|
||||||
Resource("pods").
|
Resource("pods").
|
||||||
Namespace(namespace).
|
Namespace(namespace).
|
||||||
Name(pod.Name).
|
Name(pod.Name).
|
||||||
|
|
|
@ -24,6 +24,7 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
"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) {
|
func TestPortForward(t *testing.T) {
|
||||||
|
version := testapi.Version()
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name, version, podPath, pfPath, container string
|
name, version, podPath, pfPath, container string
|
||||||
|
@ -45,32 +47,17 @@ func TestPortForward(t *testing.T) {
|
||||||
pfErr bool
|
pfErr bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "v1beta3 - pod portforward",
|
name: "pod portforward",
|
||||||
version: "v1beta3",
|
version: version,
|
||||||
podPath: "/api/v1beta3/namespaces/test/pods/foo",
|
podPath: "/api/" + version + "/namespaces/test/pods/foo",
|
||||||
pfPath: "/api/v1beta3/namespaces/test/pods/foo/portforward",
|
pfPath: "/api/" + version + "/namespaces/test/pods/foo/portforward",
|
||||||
pod: execPod(),
|
pod: execPod(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "v1beta3 - pod portforward error",
|
name: "pod portforward error",
|
||||||
version: "v1beta3",
|
version: version,
|
||||||
podPath: "/api/v1beta3/namespaces/test/pods/foo",
|
podPath: "/api/" + version + "/namespaces/test/pods/foo",
|
||||||
pfPath: "/api/v1beta3/namespaces/test/pods/foo/portforward",
|
pfPath: "/api/" + version + "/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",
|
|
||||||
pod: execPod(),
|
pod: execPod(),
|
||||||
pfErr: true,
|
pfErr: true,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue