From 7897ea8c28bb419bb5cae9ae1a25a9ecc055f304 Mon Sep 17 00:00:00 2001 From: deads2k Date: Fri, 27 Jan 2017 11:38:32 -0500 Subject: [PATCH] remove httpstream dependency on pkg/api --- .../pkg/util/httpstream/httpstream_test.go | 4 +--- .../pkg/util/httpstream/spdy/roundtripper.go | 17 +++++++++++++++-- vendor/BUILD | 4 ++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/staging/src/k8s.io/apimachinery/pkg/util/httpstream/httpstream_test.go b/staging/src/k8s.io/apimachinery/pkg/util/httpstream/httpstream_test.go index b528089bf5..f7f9a3ebf4 100644 --- a/staging/src/k8s.io/apimachinery/pkg/util/httpstream/httpstream_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/util/httpstream/httpstream_test.go @@ -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) } } diff --git a/staging/src/k8s.io/apimachinery/pkg/util/httpstream/spdy/roundtripper.go b/staging/src/k8s.io/apimachinery/pkg/util/httpstream/spdy/roundtripper.go index 8678d33553..cf5fbe9be3 100644 --- a/staging/src/k8s.io/apimachinery/pkg/util/httpstream/spdy/roundtripper.go +++ b/staging/src/k8s.io/apimachinery/pkg/util/httpstream/spdy/roundtripper.go @@ -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{}, + ) +} diff --git a/vendor/BUILD b/vendor/BUILD index 22148148a3..8eff5891fb 100644 --- a/vendor/BUILD +++ b/vendor/BUILD @@ -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",