Skip to content

Commit e2e5b92

Browse files
committed
Show error message when kubernetes configuration cannot be parsed
This PR fixes #2603. Signed-off-by: Denis Golovin [email protected]
1 parent ba8474e commit e2e5b92

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/util/kubeUtils.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import * as fs from 'fs';
77
import * as path from 'path';
8-
import { QuickPickItem } from 'vscode';
8+
import { commands, QuickPickItem, window } from 'vscode';
99
import { KubeConfig, findHomeDir, loadYaml } from '@kubernetes/client-node';
1010
import { User, Cluster } from '@kubernetes/client-node/dist/config_types';
1111

@@ -19,9 +19,14 @@ function fileExists(file: string): boolean {
1919
}
2020

2121
export class KubeConfigUtils extends KubeConfig {
22+
public readonly loadingError: any;
2223
constructor() {
2324
super();
24-
this.loadFromDefault();
25+
try {
26+
this.loadFromDefault();
27+
} catch (error) {
28+
throw new Error('Kubernetes configuration file cannot be parsed. Please open it in editor and fix the errors to continue.');
29+
}
2530
// k8s nodejs-client ignores all unknown properties,
2631
// so cluster object's proxy-url attribute is not present
2732
// after k8s config loaded

0 commit comments

Comments
 (0)