Always set ?namespace in query if specified

Revise our code to only call Request.Namespace() if a namespace
*should* be present.  For root scoped resources, namespace should
be ignored.  For namespaced resources, it is an error to have
Namespace=="".
This commit is contained in:
Clayton Coleman
2015-02-15 23:43:45 -05:00
parent 9175082a1c
commit 3e2e4714a2
10 changed files with 100 additions and 63 deletions

View File

@@ -277,7 +277,13 @@ func TestBind(t *testing.T) {
table := []struct {
binding *api.Binding
}{
{binding: &api.Binding{PodID: "foo", Host: "foohost.kubernetes.mydomain.com"}},
{binding: &api.Binding{
ObjectMeta: api.ObjectMeta{
Namespace: api.NamespaceDefault,
},
PodID: "foo",
Host: "foohost.kubernetes.mydomain.com",
}},
}
for _, item := range table {
@@ -296,7 +302,7 @@ func TestBind(t *testing.T) {
continue
}
expectedBody := runtime.EncodeOrDie(testapi.Codec(), item.binding)
handler.ValidateRequest(t, "/api/"+testapi.Version()+"/bindings", "POST", &expectedBody)
handler.ValidateRequest(t, "/api/"+testapi.Version()+"/bindings?namespace=default", "POST", &expectedBody)
}
}