Don't error out if we can't find resources from helm in our cluster, and handle "blank" output from kubectl gracefully. (#6039)

This commit is contained in:
Michael Pearson authored and GitHub committed 2022-08-18 08:21:24 -04:00
1 parent 3f2010a6b6
commit 5249a8ebed
1 file changed
+11 -2
+11 -2
View File
@@ -194,6 +194,11 @@ async function getResources(name: string, namespace: string, kubeconfigPath: str
"--kubeconfig", kubeconfigPath,
"-f", "-",
"--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 {
@@ -208,9 +213,13 @@ async function getResources(name: string, namespace: string, kubeconfigPath: str
.on("exit", (code, signal) => {
if (typeof code === "number") {
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 {
reject(stderr);
}