Merge pull request #4342 from derekwaynecarr/ns_context_update

If I access an individual namespace, the namespace context for request should match name
pull/6/head
Clayton Coleman 2015-02-11 16:16:59 -05:00
commit 1df343582b
2 changed files with 4 additions and 2 deletions

View File

@ -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]

View File

@ -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"}},