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

@@ -42,7 +42,7 @@ func buildResourcePath(prefix, namespace, resource string) string {
base := path.Join("/api", testapi.Version(), prefix)
if len(namespace) > 0 {
if !(testapi.Version() == "v1beta1" || testapi.Version() == "v1beta2") {
base = path.Join(base, "ns", namespace)
base = path.Join(base, "namespaces", namespace)
}
}
return path.Join(base, resource)
@@ -58,10 +58,8 @@ func buildQueryValues(namespace string, query url.Values) url.Values {
}
}
}
if len(namespace) > 0 {
if testapi.Version() == "v1beta1" || testapi.Version() == "v1beta2" {
v.Set("namespace", namespace)
}
if testapi.Version() == "v1beta1" || testapi.Version() == "v1beta2" {
v.Set("namespace", namespace)
}
return v
}