From 7b34d6ef8e08924ff17408023db736ac51eb819c Mon Sep 17 00:00:00 2001 From: derekwaynecarr Date: Wed, 11 Feb 2015 14:53:32 -0500 Subject: [PATCH] The namespace context for a get of an individual namespace is the namespace --- pkg/apiserver/handlers.go | 4 +++- pkg/apiserver/handlers_test.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/apiserver/handlers.go b/pkg/apiserver/handlers.go index 8bf0df9020b..dfc1711b353 100644 --- a/pkg/apiserver/handlers.go +++ b/pkg/apiserver/handlers.go @@ -292,8 +292,10 @@ func (r *APIRequestInfoResolver) GetAPIRequestInfo(req *http.Request) (APIReques // URL forms: /namespaces/{namespace}/{kind}/*, where parts are adjusted to be relative to kind if currentParts[0] == "namespaces" { if len(currentParts) < 3 { - requestInfo.Namespace = "" requestInfo.Resource = "namespaces" + if len(currentParts) > 1 { + requestInfo.Namespace = currentParts[1] + } } else { requestInfo.Resource = currentParts[2] requestInfo.Namespace = currentParts[1] diff --git a/pkg/apiserver/handlers_test.go b/pkg/apiserver/handlers_test.go index 5e969476e6b..59509c9699f 100644 --- a/pkg/apiserver/handlers_test.go +++ b/pkg/apiserver/handlers_test.go @@ -80,7 +80,7 @@ func TestGetAPIRequestInfo(t *testing.T) { // resource paths {"GET", "/namespaces", "list", "", "", "namespaces", "Namespace", "", []string{"namespaces"}}, - {"GET", "/namespaces/other", "get", "", "", "namespaces", "Namespace", "other", []string{"namespaces", "other"}}, + {"GET", "/namespaces/other", "get", "", "other", "namespaces", "Namespace", "other", []string{"namespaces", "other"}}, {"GET", "/namespaces/other/pods", "list", "", "other", "pods", "Pod", "", []string{"pods"}}, {"GET", "/namespaces/other/pods/foo", "get", "", "other", "pods", "Pod", "foo", []string{"pods", "foo"}},