chore: Extract @k8slens/kube-object package

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton committed 2023-05-02 10:11:52 -07:00
1 parent 576373b16b
commit 1bf24db797
466 files changed
+6838 -6375

No files matched your search

@@ -6,7 +6,7 @@ import { getInjectable } from "@ogre-tools/injectable";
import type { AsyncResult } from "@k8slens/utilities";
import execHelmInjectable from "../../../exec-helm/exec-helm.injectable";
import yaml from "js-yaml";
import type { KubeJsonApiData, KubeJsonApiDataList } from "../../../../../common/k8s-api/kube-json-api";
import type { KubeJsonApiData, KubeJsonApiDataList } from "@k8slens/kube-object";
const callForHelmManifestInjectable = getInjectable({
id: "call-for-helm-manifest",
@@ -9,7 +9,7 @@ import execFileWithInputInjectable from "./exec-file-with-input/exec-file-with-i
import { getErrorMessage } from "../../../../../common/utils/get-error-message";
import { map } from "lodash/fp";
import { pipeline } from "@ogre-tools/fp";
import type { KubeJsonApiData } from "../../../../../common/k8s-api/kube-json-api";
import type { KubeJsonApiData } from "@k8slens/kube-object";
export type CallForKubeResourcesByManifest = (
namespace: string,
@@ -4,7 +4,7 @@
*/
import { getInjectable } from "@ogre-tools/injectable";
import callForHelmManifestInjectable from "./call-for-helm-manifest/call-for-helm-manifest.injectable";
import type { KubeJsonApiData, KubeJsonApiDataList } from "../../../../common/k8s-api/kube-json-api";
import type { KubeJsonApiData, KubeJsonApiDataList } from "@k8slens/kube-object";
import type { AsyncResult } from "@k8slens/utilities";
export type GetHelmReleaseResources = (
@@ -13,7 +13,7 @@ import asyncFn from "@async-fn/jest";
import type { ExecFileWithInput } from "./call-for-kube-resources-by-manifest/exec-file-with-input/exec-file-with-input.injectable";
import execFileWithInputInjectable from "./call-for-kube-resources-by-manifest/exec-file-with-input/exec-file-with-input.injectable";
import type { AsyncResult } from "@k8slens/utilities";
import type { KubeJsonApiData } from "../../../../common/k8s-api/kube-json-api";
import type { KubeJsonApiData } from "@k8slens/kube-object";
describe("get helm release resources", () => {
let getHelmReleaseResources: GetHelmReleaseResources;
@@ -15,6 +15,7 @@ import type { CreateKubeJsonApiForCluster } from "../../../common/k8s-api/create
import type { CreateKubeApi } from "../../../common/k8s-api/create-kube-api.injectable";
import { initialNodeShellImage } from "../../../common/cluster-types";
import type { LoadProxyKubeconfig } from "../../cluster/load-proxy-kubeconfig.injectable";
import type { Pod } from "@k8slens/kube-object";
export interface NodeShellSessionArgs extends ShellSessionArgs {
nodeName: string;
@@ -148,13 +149,13 @@ export class NodeShellSession extends ShellSession {
.watch(`/api/v1/namespaces/kube-system/pods`,
{},
// callback is called for each received object.
(type, { metadata: { name }, status }) => {
(type, { metadata: { name }, status }: Pod) => {
if (name === this.podName) {
switch (status.phase) {
switch (status?.phase) {
case "Running":
return resolve();
case "Failed":
return reject(`Failed to be created: ${status.message || "unknown error"}`);
return reject(`Failed to be created: ${(status as unknown as Record<string, string>).message || "unknown error"}`);
}
}
},
@@ -167,12 +168,13 @@ export class NodeShellSession extends ShellSession {
.then(req => {
setTimeout(() => {
this.dependencies.logger.error(`[NODE-SHELL]: aborting wait for ${this.podName}, timing out`);
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
req.abort();
reject("Pod creation timed out");
}, 2 * 60 * 1000); // 2 * 60 * 1000
})
.catch(error => {
this.dependencies.logger.error(`[NODE-SHELL]: waiting for ${this.podName} failed: ${error}`);
this.dependencies.logger.error(`[NODE-SHELL]: waiting for ${this.podName} failed: ${String(error)}`);
reject(error);
});
});