Flatten user preferences in user store (#2587)

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2021-04-27 09:44:02 -04:00
1 parent 119d584bcb
commit afa5379ba9
16 files changed
+212 -116

No files matched your search

+7 -7
View File
@@ -113,12 +113,12 @@ export class Kubectl {
}
public getPathFromPreferences() {
return UserStore.getInstance().preferences?.kubectlBinariesPath || this.getBundledPath();
return UserStore.getInstance().kubectlBinariesPath || this.getBundledPath();
}
protected getDownloadDir() {
if (UserStore.getInstance().preferences?.downloadBinariesPath) {
return path.join(UserStore.getInstance().preferences.downloadBinariesPath, "kubectl");
if (UserStore.getInstance().downloadBinariesPath) {
return path.join(UserStore.getInstance().downloadBinariesPath, "kubectl");
}
return Kubectl.kubectlDir;
@@ -129,7 +129,7 @@ export class Kubectl {
return this.getBundledPath();
}
if (UserStore.getInstance().preferences?.downloadKubectlBinaries === false) {
if (UserStore.getInstance().downloadKubectlBinaries === false) {
return this.getPathFromPreferences();
}
@@ -223,7 +223,7 @@ export class Kubectl {
}
public async ensureKubectl(): Promise<boolean> {
if (UserStore.getInstance().preferences?.downloadKubectlBinaries === false) {
if (UserStore.getInstance().downloadKubectlBinaries === false) {
return true;
}
@@ -303,7 +303,7 @@ export class Kubectl {
}
protected async writeInitScripts() {
const kubectlPath = UserStore.getInstance().preferences?.downloadKubectlBinaries ? this.dirname : path.dirname(this.getPathFromPreferences());
const kubectlPath = UserStore.getInstance().downloadKubectlBinaries ? this.dirname : path.dirname(this.getPathFromPreferences());
const helmPath = helmCli.getBinaryDir();
const fsPromises = fs.promises;
const bashScriptPath = path.join(this.dirname, ".bash_set_path");
@@ -361,7 +361,7 @@ export class Kubectl {
}
protected getDownloadMirror() {
const mirror = packageMirrors.get(UserStore.getInstance().preferences?.downloadMirror);
const mirror = packageMirrors.get(UserStore.getInstance().downloadMirror);
if (mirror) {
return mirror;
@@ -21,8 +21,8 @@ export class LocalShellSession extends ShellSession {
protected async getShellArgs(shell: string): Promise<string[]> {
const helmpath = helmCli.getBinaryDir();
const pathFromPreferences = UserStore.getInstance().preferences.kubectlBinariesPath || this.kubectl.getBundledPath();
const kubectlPathDir = UserStore.getInstance().preferences.downloadKubectlBinaries ? await this.kubectlBinDirP : path.dirname(pathFromPreferences);
const pathFromPreferences = UserStore.getInstance().kubectlBinariesPath || this.kubectl.getBundledPath();
const kubectlPathDir = UserStore.getInstance().downloadKubectlBinaries ? await this.kubectlBinDirP : path.dirname(pathFromPreferences);
switch(path.basename(shell)) {
case "powershell.exe":
+1 -1
View File
@@ -119,7 +119,7 @@ export abstract class ShellSession {
protected async getShellEnv() {
const env = clearKubeconfigEnvVars(JSON.parse(JSON.stringify(await shellEnv())));
const pathStr = [...this.getPathEntries(), await this.kubectlBinDirP, process.env.PATH].join(path.delimiter);
const shell = UserStore.getInstance().preferences.shell || process.env.SHELL || process.env.PTYSHELL;
const shell = UserStore.getInstance().resolvedShell;
delete env.DEBUG; // don't pass DEBUG into shells