Skip to content

Commit

Permalink
Fixes the extension activation when 'KUBECONGIG' env. variable is mis…
Browse files Browse the repository at this point in the history
…configured

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 <[email protected]>
  • Loading branch information
vrubezhny committed Nov 29, 2024
1 parent 938dd6f commit 74731b6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
}
try {
const kubeconfigFiles = getKubeConfigFiles();
this.kubeConfigWatchers = kubeconfigFiles.map(kubeconfigFile => WatchUtil.watchFileForContextChange(path.dirname(kubeconfigFile), path.basename(kubeconfigFile)));
this.kubeConfigWatchers = (!kubeconfigFiles || kubeconfigFiles.length === 0) ? [] :
kubeconfigFiles.map(kubeconfigFile => WatchUtil.watchFileForContextChange(path.dirname(kubeconfigFile), path.basename(kubeconfigFile)));
if (this.kubeConfigWatchers.length === 0) {
void window.showWarningMessage('Kubernetes configuration file(s) not found. Make sure that "${HOME}/.kube/config" file exists or "KUBECONFIG" environment variable is properly configured');
}
} catch {
void window.showWarningMessage('Couldn\'t install watcher for Kubernetes configuration file. OpenShift Application Explorer view won\'t be updated automatically.');
}
Expand Down

0 comments on commit 74731b6

Please sign in to comment.