React to upstream spdy executor changes
Signed-off-by: Andy Goldstein <andy.goldstein@gmail.com>pull/157/head
parent
322cbc19e6
commit
293674c40e
|
@ -26,7 +26,6 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
kapiv1 "k8s.io/api/core/v1"
|
||||
remotecommandconsts "k8s.io/apimachinery/pkg/util/remotecommand"
|
||||
kscheme "k8s.io/client-go/kubernetes/scheme"
|
||||
"k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/tools/remotecommand"
|
||||
|
@ -129,7 +128,7 @@ func (e *defaultPodCommandExecutor) executePodCommand(log *logrus.Entry, item ma
|
|||
Stderr: true,
|
||||
}, kscheme.ParameterCodec)
|
||||
|
||||
executor, err := e.streamExecutorFactory.NewExecutor(e.restClientConfig, "POST", req.URL())
|
||||
executor, err := e.streamExecutorFactory.NewSPDYExecutor(e.restClientConfig, "POST", req.URL())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -137,9 +136,8 @@ func (e *defaultPodCommandExecutor) executePodCommand(log *logrus.Entry, item ma
|
|||
var stdout, stderr bytes.Buffer
|
||||
|
||||
streamOptions := remotecommand.StreamOptions{
|
||||
SupportedProtocols: remotecommandconsts.SupportedStreamingProtocols,
|
||||
Stdout: &stdout,
|
||||
Stderr: &stderr,
|
||||
Stdout: &stdout,
|
||||
Stderr: &stderr,
|
||||
}
|
||||
|
||||
errCh := make(chan error)
|
||||
|
@ -215,11 +213,11 @@ func setDefaultHookContainer(pod map[string]interface{}, hook *api.ExecHook) err
|
|||
}
|
||||
|
||||
type streamExecutorFactory interface {
|
||||
NewExecutor(config *rest.Config, method string, url *url.URL) (remotecommand.StreamExecutor, error)
|
||||
NewSPDYExecutor(config *rest.Config, method string, url *url.URL) (remotecommand.Executor, error)
|
||||
}
|
||||
|
||||
type defaultStreamExecutorFactory struct{}
|
||||
|
||||
func (f *defaultStreamExecutorFactory) NewExecutor(config *rest.Config, method string, url *url.URL) (remotecommand.StreamExecutor, error) {
|
||||
return remotecommand.NewExecutor(config, method, url)
|
||||
func (f *defaultStreamExecutorFactory) NewSPDYExecutor(config *rest.Config, method string, url *url.URL) (remotecommand.Executor, error) {
|
||||
return remotecommand.NewSPDYExecutor(config, method, url)
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
remotecommandconsts "k8s.io/apimachinery/pkg/util/remotecommand"
|
||||
"k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/tools/remotecommand"
|
||||
)
|
||||
|
@ -201,13 +200,12 @@ func TestExecutePodCommand(t *testing.T) {
|
|||
expectedURL, _ := url.Parse(
|
||||
fmt.Sprintf("https://some.server/api/v1/namespaces/namespace/pods/name/exec?command=%s&container=%s&stderr=true&stdout=true", expectedCommand, test.expectedContainerName),
|
||||
)
|
||||
streamExecutorFactory.On("NewExecutor", clientConfig, "POST", expectedURL).Return(streamExecutor, nil)
|
||||
streamExecutorFactory.On("NewSPDYExecutor", clientConfig, "POST", expectedURL).Return(streamExecutor, nil)
|
||||
|
||||
var stdout, stderr bytes.Buffer
|
||||
expectedStreamOptions := remotecommand.StreamOptions{
|
||||
SupportedProtocols: remotecommandconsts.SupportedStreamingProtocols,
|
||||
Stdout: &stdout,
|
||||
Stderr: &stderr,
|
||||
Stdout: &stdout,
|
||||
Stderr: &stderr,
|
||||
}
|
||||
streamExecutor.On("Stream", expectedStreamOptions).Return(test.hookError)
|
||||
|
||||
|
@ -244,14 +242,14 @@ type mockStreamExecutorFactory struct {
|
|||
mock.Mock
|
||||
}
|
||||
|
||||
func (f *mockStreamExecutorFactory) NewExecutor(config *rest.Config, method string, url *url.URL) (remotecommand.StreamExecutor, error) {
|
||||
func (f *mockStreamExecutorFactory) NewSPDYExecutor(config *rest.Config, method string, url *url.URL) (remotecommand.Executor, error) {
|
||||
args := f.Called(config, method, url)
|
||||
return args.Get(0).(remotecommand.StreamExecutor), args.Error(1)
|
||||
return args.Get(0).(remotecommand.Executor), args.Error(1)
|
||||
}
|
||||
|
||||
type mockStreamExecutor struct {
|
||||
mock.Mock
|
||||
remotecommand.StreamExecutor
|
||||
remotecommand.Executor
|
||||
}
|
||||
|
||||
func (e *mockStreamExecutor) Stream(options remotecommand.StreamOptions) error {
|
||||
|
|
Loading…
Reference in New Issue