vscode-kubernetes-tools / vscode-kubernetes-tools-api

A NPM package for building Kubernetes extensions for Visual Studio Code
Other
9 stars 15 forks source link

Add API function to return current kubeconfig file #18

Closed madelineliao closed 4 years ago

madelineliao commented 5 years ago

It'd be helpful to have a function that returns the path of the current kubeconfig file that's associated with the clusters displayed in the sidebar.

Currently, I have to do the following to retrieve the file:

function getKubeConfig () : string {
    let kubeConfig = vscode.workspace.getConfiguration("vs-kubernetes")["vs-kubernetes.kubeconfig"];
    if (!kubeConfig) {
        kubeConfig = process.env.KUBECONFIG;
    }

    if (!kubeConfig) {
        kubeConfig = `${HOME}${path.sep}.kube${path.sep}config`; // default kubeconfig value
    }

    return kubeConfig;  
}
itowlson commented 4 years ago

Fixed via #21 (very belatedly, sorry @madelineliao).