diff --git a/assets/app/scripts/services/data.js b/assets/app/scripts/services/data.js index 8f0f7e4a5603..dac568f7d9d5 100644 --- a/assets/app/scripts/services/data.js +++ b/assets/app/scripts/services/data.js @@ -570,6 +570,9 @@ angular.module('openshiftConsole') var URL_WATCH_LIST = URL_ROOT_TEMPLATE + "watch/{type}{?q*}"; var URL_GET_LIST = URL_ROOT_TEMPLATE + "{type}{?q*}"; var URL_GET_OBJECT = URL_ROOT_TEMPLATE + "{type}/{id}{?q*}"; + var URL_NAMESPACED_WATCH_LIST = URL_ROOT_TEMPLATE + "watch/ns/{namespace}/{type}{?q*}"; + var URL_NAMESPACED_GET_LIST = URL_ROOT_TEMPLATE + "ns/{namespace}/{type}{?q*}"; + var URL_NAMESPACED_GET_OBJECT = URL_ROOT_TEMPLATE + "ns/{namespace}/{type}/{id}{?q*}"; var apicfg = OPENSHIFT_CONFIG.api; @@ -577,6 +580,10 @@ angular.module('openshiftConsole') // Set the api version the console is currently able to talk to apicfg.openshift.version = "v1beta1"; apicfg.k8s.version = "v1beta3"; + + // Set whether namespace is a path or query parameter + apicfg.openshift.namespacePath = false; + apicfg.k8s.namespacePath = true; // TODO this is not the ideal, issue open to discuss adding // an introspection endpoint that would give us this mapping @@ -597,6 +604,7 @@ angular.module('openshiftConsole') }; DataService.prototype._urlForType = function(type, id, context, isWebsocket, params) { + var params = params || {}; var protocol; if (isWebsocket) { protocol = window.location.protocol === "http:" ? "ws" : "wss"; @@ -605,15 +613,22 @@ angular.module('openshiftConsole') protocol = window.location.protocol === "http:" ? "http" : "https"; } + var namespaceInPath = params.namespace && SERVER_TYPE_MAP[type].namespacePath; + var namespace = null; + if (namespaceInPath) { + namespace = params.namespace; + params = angular.copy(params); + delete params.namespace; + } var template; if (isWebsocket) { - template = URL_WATCH_LIST; + template = namespaceInPath ? URL_NAMESPACED_WATCH_LIST : URL_WATCH_LIST; } else if (id) { - template = URL_GET_OBJECT; + template = namespaceInPath ? URL_NAMESPACED_GET_OBJECT : URL_GET_OBJECT; } else { - template = URL_GET_LIST; + template = namespaceInPath ? URL_NAMESPACED_GET_LIST : URL_GET_LIST; } // TODO where do we specify what the server URL and api version should be @@ -624,6 +639,7 @@ angular.module('openshiftConsole') apiVersion: SERVER_TYPE_MAP[type].version, type: type, id: id, + namespace: namespace, q: params }); }; diff --git a/pkg/assets/bindata.go b/pkg/assets/bindata.go index 30c1f1e6c56c..5ecd0e2149c2 100644 --- a/pkg/assets/bindata.go +++ b/pkg/assets/bindata.go @@ -12999,32 +12999,35 @@ f._watchCallbacks(a, b).fire(f._data(a, b), e.type, e.object); }, f.prototype.objectsByAttribute = function(a, b, c, d, e) { for (var f = 0; f < a.length; f++) g(a[f], b, c, d ? d[f] :null, e); }; -var h = "{protocol}://{+serverUrl}{+apiPrefix}/{apiVersion}/", i = h + "watch/{type}{?q*}", j = h + "{type}{?q*}", k = h + "{type}/{id}{?q*}", l = OPENSHIFT_CONFIG.api; -l.openshift.version = "v1beta1", l.k8s.version = "v1beta3"; -var m = { -builds:l.openshift, -deploymentConfigs:l.openshift, -images:l.openshift, -oAuthAccessTokens:l.openshift, -projects:l.openshift, -users:l.openshift, -pods:l.k8s, -replicationcontrollers:l.k8s, -services:l.k8s, -resourcequotas:l.k8s, -limitranges:l.k8s +var h = "{protocol}://{+serverUrl}{+apiPrefix}/{apiVersion}/", i = h + "watch/{type}{?q*}", j = h + "{type}{?q*}", k = h + "{type}/{id}{?q*}", l = h + "watch/ns/{namespace}/{type}{?q*}", m = h + "ns/{namespace}/{type}{?q*}", n = h + "ns/{namespace}/{type}/{id}{?q*}", o = OPENSHIFT_CONFIG.api; +o.openshift.version = "v1beta1", o.k8s.version = "v1beta3", o.openshift.namespacePath = !1, o.k8s.namespacePath = !0; +var p = { +builds:o.openshift, +deploymentConfigs:o.openshift, +images:o.openshift, +oAuthAccessTokens:o.openshift, +projects:o.openshift, +users:o.openshift, +pods:o.k8s, +replicationcontrollers:o.k8s, +services:o.k8s, +resourcequotas:o.k8s, +limitranges:o.k8s }; return f.prototype._urlForType = function(a, b, c, d, e) { -var f; +var f, e = e || {}; f = d ? "http:" === window.location.protocol ? "ws" :"wss" :"http:" === window.location.protocol ? "http" :"https"; -var g; -return g = d ? i :b ? k :j, URI.expand(g, { +var g = e.namespace && p[a].namespacePath, h = null; +g && (h = e.namespace, e = angular.copy(e), delete e.namespace); +var o; +return o = d ? g ? l :i :b ? g ? n :k :g ? m :j, URI.expand(o, { protocol:f, -serverUrl:m[a].hostPort, -apiPrefix:m[a].prefix, -apiVersion:m[a].version, +serverUrl:p[a].hostPort, +apiPrefix:p[a].prefix, +apiVersion:p[a].version, type:a, id:b, +namespace:h, q:e }); }, new f();