Skip to content

Commit 74731b6

Browse files
committed
Fixes the extension activation when 'KUBECONGIG' env. variable is misconfigured
Prevents the extension activation failure in case of 'KUBECONFIG' variable doesn't contain any existing Kubernetes configuration file set. Issue: redhat-developer#3872 Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
1 parent 938dd6f commit 74731b6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/explorer.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,11 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
118118
}
119119
try {
120120
const kubeconfigFiles = getKubeConfigFiles();
121-
this.kubeConfigWatchers = kubeconfigFiles.map(kubeconfigFile => WatchUtil.watchFileForContextChange(path.dirname(kubeconfigFile), path.basename(kubeconfigFile)));
121+
this.kubeConfigWatchers = (!kubeconfigFiles || kubeconfigFiles.length === 0) ? [] :
122+
kubeconfigFiles.map(kubeconfigFile => WatchUtil.watchFileForContextChange(path.dirname(kubeconfigFile), path.basename(kubeconfigFile)));
123+
if (this.kubeConfigWatchers.length === 0) {
124+
void window.showWarningMessage('Kubernetes configuration file(s) not found. Make sure that "${HOME}/.kube/config" file exists or "KUBECONFIG" environment variable is properly configured');
125+
}
122126
} catch {
123127
void window.showWarningMessage('Couldn\'t install watcher for Kubernetes configuration file. OpenShift Application Explorer view won\'t be updated automatically.');
124128
}

0 commit comments

Comments
 (0)