From f299b84fd445c91aea11dbf4eaedf72c88f41ad6 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Mon, 14 Sep 2020 14:59:21 -0400 Subject: [PATCH] make download dir option consitent with other settings Signed-off-by: Sebastian Malton --- src/common/user-store.ts | 2 -- src/main/kubectl.ts | 10 +++++++--- .../+preferences/kubectl-binaries.tsx | 20 ++++++++++--------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/common/user-store.ts b/src/common/user-store.ts index a0cfe09fd5..f7d3ade005 100644 --- a/src/common/user-store.ts +++ b/src/common/user-store.ts @@ -59,8 +59,6 @@ export class UserStore extends BaseStore { colorTheme: UserStore.defaultTheme, downloadMirror: "default", downloadKubectlBinaries: true, // Download kubectl binaries matching cluster version - downloadBinariesPath: this.getDefaultKubectlPath(), - kubectlBinariesPath: "" }; get isNewVersion() { diff --git a/src/main/kubectl.ts b/src/main/kubectl.ts index afb7a89111..1e57e29d5d 100644 --- a/src/main/kubectl.ts +++ b/src/main/kubectl.ts @@ -36,7 +36,7 @@ const packageMirrors: Map = new Map([ let bundledPath: string const initScriptVersionString = "# lens-initscript v3\n" -if (isDevelopment || isTestEnv) { +if (isDevelopment || isTestEnv) { const platformName = isWindows ? "windows" : process.platform bundledPath = path.join(process.cwd(), "binaries", "client", platformName, process.arch, "kubectl") } else { @@ -110,7 +110,11 @@ export class Kubectl { } protected getDownloadDir() { - return userStore.preferences?.downloadBinariesPath || Kubectl.kubectlDir + if (userStore.preferences?.downloadBinariesPath) { + return path.join(userStore.preferences.downloadBinariesPath, "kubectl") + } + + return Kubectl.kubectlDir } public async getPath(bundled = false): Promise { @@ -214,7 +218,7 @@ export class Kubectl { }); isValid = !await this.checkBinary(this.path, false) } - if(!isValid) { + if (!isValid) { logger.debug(`Releasing lock for ${this.kubectlVersion}`) release() return false diff --git a/src/renderer/components/+preferences/kubectl-binaries.tsx b/src/renderer/components/+preferences/kubectl-binaries.tsx index 15b01251f4..da06109efe 100644 --- a/src/renderer/components/+preferences/kubectl-binaries.tsx +++ b/src/renderer/components/+preferences/kubectl-binaries.tsx @@ -13,6 +13,8 @@ export const KubectlBinaries = observer(({ preferences }: { preferences: UserPre const [downloadPath, setDownloadPath] = useState(preferences.downloadBinariesPath || ""); const [binariesPath, setBinariesPath] = useState(preferences.kubectlBinariesPath || ""); + console.log(preferences); + const downloadMirrorOptions: SelectOption[] = [ { value: "default", label: "Default (Google)" }, { value: "china", label: "China (Azure)" }, @@ -30,7 +32,7 @@ export const KubectlBinaries = observer(({ preferences }: { preferences: UserPre } return ( <> - +

Kubectl Binary

- - Download kubectl binaries matching to Kubernetes cluster verison. - Download kubectl binaries} value={preferences.downloadKubectlBinaries} onChange={downloadKubectlBinaries => preferences.downloadKubectlBinaries = downloadKubectlBinaries} /> + + Download kubectl binaries matching to Kubernetes cluster verison. + - - Default: {userStore.getDefaultKubectlPath()} + + The directory to download binaries into. {renderPath()} ); -}); \ No newline at end of file +});