remove httpstream dependency on pkg/api

pull/6/head
deads2k 2017-01-27 11:38:32 -05:00
parent 674d78b2ab
commit 7897ea8c28
3 changed files with 18 additions and 7 deletions

View File

@ -20,8 +20,6 @@ import (
"net/http"
"reflect"
"testing"
"k8s.io/kubernetes/pkg/api"
)
type responseWriter struct {
@ -120,7 +118,7 @@ func TestHandshake(t *testing.T) {
}
// verify response headers
if e, a := []string{test.expectedProtocol}, w.Header()[HeaderProtocolVersion]; !api.Semantic.DeepEqual(e, a) {
if e, a := []string{test.expectedProtocol}, w.Header()[HeaderProtocolVersion]; !reflect.DeepEqual(e, a) {
t.Errorf("%s: protocol response header: expected %v, got %v", name, e, a)
}
}

View File

@ -30,9 +30,10 @@ import (
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/apimachinery/pkg/util/httpstream"
"k8s.io/apimachinery/third_party/forked/golang/netutil"
"k8s.io/kubernetes/pkg/api"
)
// SpdyRoundTripper knows how to upgrade an HTTP request to one that supports
@ -251,7 +252,7 @@ func (s *SpdyRoundTripper) NewConnection(resp *http.Response) (httpstream.Connec
responseError = "unable to read error from server response"
} else {
// TODO: I don't belong here, I should be abstracted from this class
if obj, _, err := api.Codecs.UniversalDecoder().Decode(responseErrorBytes, nil, &metav1.Status{}); err == nil {
if obj, _, err := statusCodecs.UniversalDecoder().Decode(responseErrorBytes, nil, &metav1.Status{}); err == nil {
if status, ok := obj.(*metav1.Status); ok {
return nil, &apierrors.StatusError{ErrStatus: *status}
}
@ -265,3 +266,15 @@ func (s *SpdyRoundTripper) NewConnection(resp *http.Response) (httpstream.Connec
return NewClientConnection(s.conn)
}
// statusScheme is private scheme for the decoding here until someone fixes the TODO in NewConnection
var statusScheme = runtime.NewScheme()
// ParameterCodec knows about query parameters used with the meta v1 API spec.
var statusCodecs = serializer.NewCodecFactory(statusScheme)
func init() {
statusScheme.AddUnversionedTypes(metav1.SchemeGroupVersion,
&metav1.Status{},
)
}

4
vendor/BUILD vendored
View File

@ -13827,7 +13827,6 @@ go_test(
srcs = ["k8s.io/apimachinery/pkg/util/httpstream/httpstream_test.go"],
library = ":k8s.io/apimachinery/pkg/util/httpstream",
tags = ["automanaged"],
deps = ["//pkg/api:go_default_library"],
)
go_library(
@ -13863,11 +13862,12 @@ go_library(
],
tags = ["automanaged"],
deps = [
"//pkg/api:go_default_library",
"//vendor:github.com/docker/spdystream",
"//vendor:github.com/golang/glog",
"//vendor:k8s.io/apimachinery/pkg/api/errors",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/runtime",
"//vendor:k8s.io/apimachinery/pkg/runtime/serializer",
"//vendor:k8s.io/apimachinery/pkg/util/httpstream",
"//vendor:k8s.io/apimachinery/pkg/util/runtime",
"//vendor:k8s.io/apimachinery/third_party/forked/golang/netutil",