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..c57ab1b8a2 100644 --- a/src/renderer/components/+preferences/kubectl-binaries.tsx +++ b/src/renderer/components/+preferences/kubectl-binaries.tsx @@ -18,44 +18,22 @@ export const KubectlBinaries = observer(({ preferences }: { preferences: UserPre { value: "china", label: "China (Azure)" }, ] - const save = () => { preferences.downloadBinariesPath = downloadPath; preferences.kubectlBinariesPath = binariesPath; } - const renderPath = () => { - if (preferences.downloadKubectlBinaries) { - return null; - } - return ( - <> - - - - Default:{" "}{Kubectl.bundledKubectlPath} - - - ); - } - 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 version. + - - Default: {userStore.getDefaultKubectlPath()} + + The directory to download binaries into. + + + + + The path to the kubectl binary on the system. - {renderPath()} ); -}); \ No newline at end of file +});