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

Don't error out if we can't find resources from helm in our cluster, and

handle "blank" output from kubectl gracefully.

Signed-off-by: Michael Pearson <mipearson@gmail.com>
This commit is contained in:
Michael Pearson 2022-08-16 13:06:41 +10:00
parent 6d37019089
commit 72e7a2a364

View File

@ -194,6 +194,11 @@ async function getResources(name: string, namespace: string, kubeconfigPath: str
"--kubeconfig", kubeconfigPath, "--kubeconfig", kubeconfigPath,
"-f", "-", "-f", "-",
"--output", "json", "--output", "json",
// Temporary workaround for https://github.com/lensapp/lens/issues/6031
// and other potential issues where resources can't be found. Showing
// no resources is better than the app hard-locking, and at least
// the helm metadata is shown.
"--ignore-not-found",
]; ];
try { try {
@ -208,9 +213,13 @@ async function getResources(name: string, namespace: string, kubeconfigPath: str
.on("exit", (code, signal) => { .on("exit", (code, signal) => {
if (typeof code === "number") { if (typeof code === "number") {
if (code === 0) { if (code === 0) {
const output = json.parse(stdout) as { items: JsonObject[] }; if (stdout === "") {
resolve([]);
} else {
const output = json.parse(stdout) as { items: JsonObject[] };
resolve(output.items); resolve(output.items);
}
} else { } else {
reject(stderr); reject(stderr);
} }