From 9e1afbceb01acc7e0af1f6dd90ca8db05f61afb4 Mon Sep 17 00:00:00 2001 From: Kris Date: Thu, 5 Nov 2015 14:42:36 -0800 Subject: [PATCH] Remove bad heuristic path manipulation --- pkg/client/unversioned/client.go | 2 +- pkg/client/unversioned/extensions.go | 2 +- pkg/client/unversioned/request.go | 17 ------------ pkg/client/unversioned/request_test.go | 37 -------------------------- 4 files changed, 2 insertions(+), 56 deletions(-) diff --git a/pkg/client/unversioned/client.go b/pkg/client/unversioned/client.go index b24b9fa331..31026e59ce 100644 --- a/pkg/client/unversioned/client.go +++ b/pkg/client/unversioned/client.go @@ -149,7 +149,7 @@ func (c *Client) ServerVersion() (*version.Info, error) { // ServerAPIVersions retrieves and parses the list of API versions the server supports. func (c *Client) ServerAPIVersions() (*unversioned.APIVersions, error) { - body, err := c.Get().UnversionedPath("").Do().Raw() + body, err := c.Get().AbsPath("/api").Do().Raw() if err != nil { return nil, err } diff --git a/pkg/client/unversioned/extensions.go b/pkg/client/unversioned/extensions.go index dba43f575a..b4b152c63e 100644 --- a/pkg/client/unversioned/extensions.go +++ b/pkg/client/unversioned/extensions.go @@ -64,7 +64,7 @@ func (c *ExtensionsClient) ServerVersion() (*version.Info, error) { // ServerAPIVersions retrieves and parses the list of experimental API versions the // server supports. func (c *ExtensionsClient) ServerAPIVersions() (*unversioned.APIVersions, error) { - body, err := c.Get().UnversionedPath("").Do().Raw() + body, err := c.Get().AbsPath("/apis/extensions").Do().Raw() if err != nil { return nil, err } diff --git a/pkg/client/unversioned/request.go b/pkg/client/unversioned/request.go index 9d9873a9e1..944f1a3bd2 100644 --- a/pkg/client/unversioned/request.go +++ b/pkg/client/unversioned/request.go @@ -226,23 +226,6 @@ func (r *Request) NamespaceIfScoped(namespace string, scoped bool) *Request { return r } -// UnversionedPath strips the apiVersion from the baseURL before appending segments. -func (r *Request) UnversionedPath(segments ...string) *Request { - if r.err != nil { - return r - } - upath := path.Clean(r.baseURL.Path) - //TODO(jdef) this is a pretty hackish version test - if strings.HasPrefix(path.Base(upath), "v") { - upath = path.Dir(upath) - if upath == "." { - upath = "/" - } - } - r.path = path.Join(append([]string{upath}, segments...)...) - return r -} - // AbsPath overwrites an existing path with the segments provided. Trailing slashes are preserved // when a single segment is passed. func (r *Request) AbsPath(segments ...string) *Request { diff --git a/pkg/client/unversioned/request_test.go b/pkg/client/unversioned/request_test.go index 7b6d9aaf65..f7f9a7de87 100644 --- a/pkg/client/unversioned/request_test.go +++ b/pkg/client/unversioned/request_test.go @@ -995,43 +995,6 @@ func TestVerbs(t *testing.T) { } } -func TestUnversionedPath(t *testing.T) { - tt := []struct { - host string - prefix string - unversioned string - expectedPath string - }{ - {"", "", "", "/api"}, - {"", "", "versions", "/api/versions"}, - {"", "/", "", "/"}, - {"", "/versions", "", "/versions"}, - {"", "/api", "", "/api"}, - {"", "/api/vfake", "", "/api/vfake"}, - {"", "/api/vfake", "v1beta100", "/api/vfake/v1beta100"}, - {"", "/api", "/versions", "/api/versions"}, - {"", "/api", "versions", "/api/versions"}, - {"", "/a/api", "", "/a/api"}, - {"", "/a/api", "/versions", "/a/api/versions"}, - {"", "/a/api", "/versions/d/e", "/a/api/versions/d/e"}, - {"", "/a/api/vfake", "/versions/d/e", "/a/api/vfake/versions/d/e"}, - } - for i, tc := range tt { - c := NewOrDie(&Config{Host: tc.host, Prefix: tc.prefix}) - r := c.Post().Prefix("/alpha").UnversionedPath(tc.unversioned) - if r.path != tc.expectedPath { - t.Errorf("test case %d failed: unexpected path: %s, expected %s", i+1, r.path, tc.expectedPath) - } - } - for i, tc := range tt { - c := NewOrDie(&Config{Host: tc.host, Prefix: tc.prefix, Version: "v1"}) - r := c.Post().Prefix("/alpha").UnversionedPath(tc.unversioned) - if r.path != tc.expectedPath { - t.Errorf("test case %d failed: unexpected path: %s, expected %s", i+1, r.path, tc.expectedPath) - } - } -} - func TestAbsPath(t *testing.T) { expectedPath := "/bar/foo" c := NewOrDie(&Config{})