From 502204ad6d64ffda38d0926de7307a6922666262 Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Tue, 30 Dec 2014 19:30:18 -0500 Subject: [PATCH 1/2] Do not set empty field or label selectors on requests Default behavior for "" is already "everything" --- pkg/client/request.go | 3 +++ plugin/pkg/scheduler/factory/factory_test.go | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/client/request.go b/pkg/client/request.go index 0a4698c92ee..2bf56e768ab 100644 --- a/pkg/client/request.go +++ b/pkg/client/request.go @@ -180,6 +180,9 @@ func (r *Request) SelectorParam(paramName string, s labels.Selector) *Request { if r.err != nil { return r } + if s.Empty() { + return r + } return r.setParam(paramName, s.String()) } diff --git a/plugin/pkg/scheduler/factory/factory_test.go b/plugin/pkg/scheduler/factory/factory_test.go index 3075775716a..6fe76fa8601 100644 --- a/plugin/pkg/scheduler/factory/factory_test.go +++ b/plugin/pkg/scheduler/factory/factory_test.go @@ -55,7 +55,7 @@ func TestCreateLists(t *testing.T) { }{ // Minion { - location: "/api/" + testapi.Version() + "/minions?fields=", + location: "/api/" + testapi.Version() + "/minions", factory: factory.createMinionLW, }, // Assigned pod @@ -95,15 +95,15 @@ func TestCreateWatches(t *testing.T) { // Minion watch { rv: "", - location: "/api/" + testapi.Version() + "/watch/minions?fields=&resourceVersion=", + location: "/api/" + testapi.Version() + "/watch/minions?resourceVersion=", factory: factory.createMinionLW, }, { rv: "0", - location: "/api/" + testapi.Version() + "/watch/minions?fields=&resourceVersion=0", + location: "/api/" + testapi.Version() + "/watch/minions?resourceVersion=0", factory: factory.createMinionLW, }, { rv: "42", - location: "/api/" + testapi.Version() + "/watch/minions?fields=&resourceVersion=42", + location: "/api/" + testapi.Version() + "/watch/minions?resourceVersion=42", factory: factory.createMinionLW, }, // Assigned pod watches From 8005c85e6c86a9ae025229c0ac0ccf7eed485c23 Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Sun, 28 Dec 2014 19:31:20 -0500 Subject: [PATCH 2/2] Rename HttpClientFunc -> HTTPClientFunc --- pkg/client/fake.go | 4 ++-- pkg/kubectl/resthelper_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/client/fake.go b/pkg/client/fake.go index 64975530def..0ed9b4e0838 100644 --- a/pkg/client/fake.go +++ b/pkg/client/fake.go @@ -80,9 +80,9 @@ func (c *Fake) ServerAPIVersions() (*api.APIVersions, error) { return &api.APIVersions{Versions: []string{"v1beta1", "v1beta2"}}, nil } -type HttpClientFunc func(*http.Request) (*http.Response, error) +type HTTPClientFunc func(*http.Request) (*http.Response, error) -func (f HttpClientFunc) Do(req *http.Request) (*http.Response, error) { +func (f HTTPClientFunc) Do(req *http.Request) (*http.Response, error) { return f(req) } diff --git a/pkg/kubectl/resthelper_test.go b/pkg/kubectl/resthelper_test.go index 25e942c037c..4ea806f60d3 100644 --- a/pkg/kubectl/resthelper_test.go +++ b/pkg/kubectl/resthelper_test.go @@ -125,7 +125,7 @@ func TestRESTHelperCreate(t *testing.T) { tests := []struct { Resp *http.Response - RespFunc client.HttpClientFunc + RespFunc client.HTTPClientFunc HttpErr error Modify bool Object runtime.Object @@ -299,7 +299,7 @@ func TestRESTHelperUpdate(t *testing.T) { tests := []struct { Resp *http.Response - RespFunc client.HttpClientFunc + RespFunc client.HTTPClientFunc HttpErr error Overwrite bool Object runtime.Object