1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix getReleases returning inconsistent data types (#2924)

This commit is contained in:
Sebastian Malton 2021-06-01 11:53:24 -04:00 committed by GitHub
parent 06612409ef
commit 043f411ad1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 16 deletions

View File

@ -39,7 +39,7 @@ export async function listReleases(pathToKubeconfig: string, namespace?: string)
return output; return output;
} }
output.forEach((release: any, index: number) => { output.forEach((release: any, index: number) => {
output[index] = toCamelCase(release); output[index] = toCamelCase(release);
}); });
return output; return output;
@ -173,8 +173,8 @@ async function getResources(name: string, namespace: string, cluster: Cluster) {
const pathToKubeconfig = await cluster.getProxyKubeconfigPath(); const pathToKubeconfig = await cluster.getProxyKubeconfigPath();
const { stdout } = await promiseExec(`"${helm}" get manifest ${name} --namespace ${namespace} --kubeconfig ${pathToKubeconfig} | "${kubectl}" get -n ${namespace} --kubeconfig ${pathToKubeconfig} -f - -o=json`); const { stdout } = await promiseExec(`"${helm}" get manifest ${name} --namespace ${namespace} --kubeconfig ${pathToKubeconfig} | "${kubectl}" get -n ${namespace} --kubeconfig ${pathToKubeconfig} -f - -o=json`);
return stdout; return JSON.parse(stdout).items;
} catch { } catch {
return { stdout: JSON.stringify({ items: [] }) }; return [];
} }
} }

View File

@ -28,6 +28,7 @@ import type { ItemObject } from "../../item.store";
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import type { JsonApiData } from "../json-api"; import type { JsonApiData } from "../json-api";
import { buildURLPositional } from "../../../common/utils/buildUrl"; import { buildURLPositional } from "../../../common/utils/buildUrl";
import type { KubeJsonApiData } from "../kube-json-api";
interface IReleasePayload { interface IReleasePayload {
name: string; name: string;
@ -46,7 +47,7 @@ interface IReleasePayload {
} }
interface IReleaseRawDetails extends IReleasePayload { interface IReleaseRawDetails extends IReleasePayload {
resources: string; resources: KubeJsonApiData[];
} }
export interface IReleaseDetails extends IReleasePayload { export interface IReleaseDetails extends IReleasePayload {
@ -102,10 +103,8 @@ export async function listReleases(namespace?: string): Promise<HelmRelease[]> {
export async function getRelease(name: string, namespace: string): Promise<IReleaseDetails> { export async function getRelease(name: string, namespace: string): Promise<IReleaseDetails> {
const path = endpoint({ name, namespace }); const path = endpoint({ name, namespace });
const { resources: rawResources, ...details } = await apiBase.get<IReleaseRawDetails>(path);
const details = await apiBase.get<IReleaseRawDetails>(path); const resources = rawResources.map(KubeObject.create);
const items: KubeObject[] = JSON.parse(details.resources).items;
const resources = items.map(item => KubeObject.create(item));
return { return {
...details, ...details,

View File

@ -97,7 +97,7 @@ export class KubeObject<Metadata extends IKubeObjectMetadata = IKubeObjectMetada
status?: Status; status?: Status;
spec?: Spec; spec?: Spec;
static create(data: any) { static create(data: KubeJsonApiData) {
return new KubeObject(data); return new KubeObject(data);
} }