mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
bf7c5a3a29
commit
d1af67b2ef
@ -79,6 +79,18 @@ export function forCluster<T extends KubeObject>(cluster: IKubeApiCluster, kubeC
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function ensureObjectSelfLink(api: KubeApi, object: KubeJsonApiData) {
|
||||||
|
if (!object.metadata.selfLink) {
|
||||||
|
object.metadata.selfLink = createKubeApiURL({
|
||||||
|
apiPrefix: api.apiPrefix,
|
||||||
|
apiVersion: api.apiVersionWithGroup,
|
||||||
|
resource: api.apiResource,
|
||||||
|
namespace: api.isNamespaced ? object.metadata.namespace : undefined,
|
||||||
|
name: object.metadata.name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class KubeApi<T extends KubeObject = any> {
|
export class KubeApi<T extends KubeObject = any> {
|
||||||
static parseApi = parseKubeApi;
|
static parseApi = parseKubeApi;
|
||||||
|
|
||||||
@ -256,29 +268,13 @@ export class KubeApi<T extends KubeObject = any> {
|
|||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected generateSelfLink(kubeObject: T): string {
|
|
||||||
return createKubeApiURL({
|
|
||||||
apiPrefix: this.apiPrefix,
|
|
||||||
apiVersion: this.apiVersionWithGroup,
|
|
||||||
resource: this.apiResource,
|
|
||||||
namespace: this.isNamespaced ? kubeObject.getNs() : undefined,
|
|
||||||
name: kubeObject.getName(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ensureObjectSelfLink(kubeObject: T): void {
|
|
||||||
if (!kubeObject.metadata.selfLink) {
|
|
||||||
kubeObject.metadata.selfLink = this.generateSelfLink(kubeObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected parseResponse(data: KubeJsonApiData | KubeJsonApiData[] | KubeJsonApiDataList, namespace?: string): any {
|
protected parseResponse(data: KubeJsonApiData | KubeJsonApiData[] | KubeJsonApiDataList, namespace?: string): any {
|
||||||
const KubeObjectConstructor = this.objectConstructor;
|
const KubeObjectConstructor = this.objectConstructor;
|
||||||
|
|
||||||
if (KubeObject.isJsonApiData(data)) {
|
if (KubeObject.isJsonApiData(data)) {
|
||||||
const object = new KubeObjectConstructor(data);
|
const object = new KubeObjectConstructor(data);
|
||||||
|
|
||||||
this.ensureObjectSelfLink(object);
|
ensureObjectSelfLink(this, object);
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
@ -297,7 +293,7 @@ export class KubeApi<T extends KubeObject = any> {
|
|||||||
...item,
|
...item,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.ensureObjectSelfLink(object);
|
ensureObjectSelfLink(this, object);
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { stringify } from "querystring";
|
|||||||
import { autobind, EventEmitter } from "../utils";
|
import { autobind, EventEmitter } from "../utils";
|
||||||
import { KubeJsonApiData } from "./kube-json-api";
|
import { KubeJsonApiData } from "./kube-json-api";
|
||||||
import type { KubeObjectStore } from "../kube-object.store";
|
import type { KubeObjectStore } from "../kube-object.store";
|
||||||
import { KubeApi } from "./kube-api";
|
import { ensureObjectSelfLink, KubeApi } from "./kube-api";
|
||||||
import { apiManager } from "./api-manager";
|
import { apiManager } from "./api-manager";
|
||||||
import { apiPrefix, isDevelopment } from "../../common/vars";
|
import { apiPrefix, isDevelopment } from "../../common/vars";
|
||||||
import { getHostedCluster } from "../../common/cluster-store";
|
import { getHostedCluster } from "../../common/cluster-store";
|
||||||
@ -164,6 +164,8 @@ export class KubeWatchApi {
|
|||||||
api.setResourceVersion(namespace, resourceVersion);
|
api.setResourceVersion(namespace, resourceVersion);
|
||||||
api.setResourceVersion("", resourceVersion);
|
api.setResourceVersion("", resourceVersion);
|
||||||
|
|
||||||
|
ensureObjectSelfLink(api, evt.object);
|
||||||
|
|
||||||
if (store == apiManager.getStore(api)) {
|
if (store == apiManager.getStore(api)) {
|
||||||
callback(evt);
|
callback(evt);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user