mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix incorrect KubeApi.parseApi merge (namespaces parsing issue)
This commit is contained in:
parent
a75be2eade
commit
a772ef6b94
@ -52,9 +52,9 @@ export class KubeApi<T extends KubeObject = any> {
|
|||||||
switch (right.length) {
|
switch (right.length) {
|
||||||
case 1:
|
case 1:
|
||||||
name = right[0];
|
name = right[0];
|
||||||
// fallthroughcase 0:
|
// fallthrough
|
||||||
|
case 0:
|
||||||
resource = "namespaces"; // special case this due to `split` removing namespaces
|
resource = "namespaces"; // special case this due to `split` removing namespaces
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
[namespace, resource, name] = right;
|
[namespace, resource, name] = right;
|
||||||
@ -67,27 +67,28 @@ export class KubeApi<T extends KubeObject = any> {
|
|||||||
switch (left.length) {
|
switch (left.length) {
|
||||||
case 2:
|
case 2:
|
||||||
resource = left.pop();
|
resource = left.pop();
|
||||||
// fallthroughcase 1:
|
// fallthrough
|
||||||
|
case 1:
|
||||||
apiVersion = left.pop();
|
apiVersion = left.pop();
|
||||||
apiGroup = "";
|
apiGroup = "";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/**
|
/**
|
||||||
* Given that
|
* Given that
|
||||||
* - `apiVersion` is `GROUP/VERSION` and
|
* - `apiVersion` is `GROUP/VERSION` and
|
||||||
* - `VERSION` is `DNS_LABEL` which is /^[a-z0-9]((-[a-z0-9])|[a-z0-9])*$/i
|
* - `VERSION` is `DNS_LABEL` which is /^[a-z0-9]((-[a-z0-9])|[a-z0-9])*$/i
|
||||||
* where length <= 63
|
* where length <= 63
|
||||||
* - `GROUP` is /^D(\.D)*$/ where D is `DNS_LABEL` and length <= 253
|
* - `GROUP` is /^D(\.D)*$/ where D is `DNS_LABEL` and length <= 253
|
||||||
*
|
*
|
||||||
* There is no well defined selection from an array of items that were
|
* There is no well defined selection from an array of items that were
|
||||||
* seperated by '/'
|
* seperated by '/'
|
||||||
*
|
*
|
||||||
* Solution is to create a huristic. Namely:
|
* Solution is to create a huristic. Namely:
|
||||||
* 1. if '.' in left[0] then apiGroup <- left[0]
|
* 1. if '.' in left[0] then apiGroup <- left[0]
|
||||||
* 2. if left[1] matches /^v[0-9]/ then apiGroup, apiVersion <- left[0], left[1]
|
* 2. if left[1] matches /^v[0-9]/ then apiGroup, apiVersion <- left[0], left[1]
|
||||||
* 3. otherwise assume apiVersion <- left[0]
|
* 3. otherwise assume apiVersion <- left[0]
|
||||||
* 4. always resource, name <- left[(0 or 1)+1..]
|
* 4. always resource, name <- left[(0 or 1)+1..]
|
||||||
*/
|
*/
|
||||||
if (left[0].includes('.') || left[1].match(/^v[0-9]/)) {
|
if (left[0].includes('.') || left[1].match(/^v[0-9]/)) {
|
||||||
[apiGroup, apiVersion] = left;
|
[apiGroup, apiVersion] = left;
|
||||||
resource = left.slice(2).join("/")
|
resource = left.slice(2).join("/")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user