mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix: Fix selfLink being missing from requestKubeResource
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
5fb08960fe
commit
b90e04e02d
@ -3,11 +3,14 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { KubeObjectMetadata, KubeObjectScope } from "../../../../../common/k8s-api/kube-object";
|
||||
import { KubeObject } from "../../../../../common/k8s-api/kube-object";
|
||||
import { parseKubeApi } from "../../../../../common/k8s-api/kube-api-parse";
|
||||
import type { AsyncResult } from "@k8slens/utilities";
|
||||
import { getErrorMessage } from "../../../../../common/utils/get-error-message";
|
||||
import apiKubeInjectable from "../../../../k8s/api-kube.injectable";
|
||||
import type { Writable } from "type-fest";
|
||||
import type { KubeJsonApiData } from "../../../../../common/k8s-api/kube-json-api";
|
||||
import { parseKubeApi } from "../../../../../common/k8s-api/kube-api-parse";
|
||||
|
||||
export type RequestKubeResource = (selfLink: string) => AsyncResult<KubeObject | undefined>;
|
||||
|
||||
@ -17,17 +20,21 @@ const requestKubeResourceInjectable = getInjectable({
|
||||
instantiate: (di): RequestKubeResource => {
|
||||
const apiKube = di.inject(apiKubeInjectable);
|
||||
|
||||
return async (apiPath: string) => {
|
||||
const parsed = parseKubeApi(apiPath);
|
||||
return async (selfLink) => {
|
||||
const parsed = parseKubeApi(selfLink);
|
||||
|
||||
if (!parsed?.name) {
|
||||
return { callWasSuccessful: false, error: "Invalid API path" };
|
||||
}
|
||||
|
||||
try {
|
||||
const rawData = await apiKube.get(selfLink) as KubeJsonApiData<KubeObjectMetadata<KubeObjectScope>, unknown, unknown>;
|
||||
|
||||
(rawData.metadata as Writable<typeof rawData.metadata>).selfLink = selfLink;
|
||||
|
||||
return {
|
||||
callWasSuccessful: true,
|
||||
response: new KubeObject(await apiKube.get(apiPath)),
|
||||
response: new KubeObject(rawData),
|
||||
};
|
||||
} catch (e) {
|
||||
return { callWasSuccessful: false, error: getErrorMessage(e) };
|
||||
|
||||
Loading…
Reference in New Issue
Block a user