mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
make download dir option consitent with other settings
Signed-off-by: Sebastian Malton <smalton@mirantis.com>
This commit is contained in:
parent
cc973bb9ef
commit
f299b84fd4
@ -59,8 +59,6 @@ export class UserStore extends BaseStore<UserStoreModel> {
|
||||
colorTheme: UserStore.defaultTheme,
|
||||
downloadMirror: "default",
|
||||
downloadKubectlBinaries: true, // Download kubectl binaries matching cluster version
|
||||
downloadBinariesPath: this.getDefaultKubectlPath(),
|
||||
kubectlBinariesPath: ""
|
||||
};
|
||||
|
||||
get isNewVersion() {
|
||||
|
||||
@ -36,7 +36,7 @@ const packageMirrors: Map<string, string> = 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<string> {
|
||||
@ -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
|
||||
|
||||
@ -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<string>[] = [
|
||||
{ value: "default", label: "Default (Google)" },
|
||||
{ value: "china", label: "China (Azure)" },
|
||||
@ -30,7 +32,7 @@ export const KubectlBinaries = observer(({ preferences }: { preferences: UserPre
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<SubTitle title="Path to Kubectl binary"/>
|
||||
<SubTitle title="Path to Kubectl binary" />
|
||||
<Input
|
||||
theme="round-black"
|
||||
value={binariesPath}
|
||||
@ -48,14 +50,14 @@ export const KubectlBinaries = observer(({ preferences }: { preferences: UserPre
|
||||
return (
|
||||
<>
|
||||
<h2><Trans>Kubectl Binary</Trans></h2>
|
||||
<small className="hint">
|
||||
<Trans>Download kubectl binaries matching to Kubernetes cluster verison.</Trans>
|
||||
</small>
|
||||
<Checkbox
|
||||
label={<Trans>Download kubectl binaries</Trans>}
|
||||
value={preferences.downloadKubectlBinaries}
|
||||
onChange={downloadKubectlBinaries => preferences.downloadKubectlBinaries = downloadKubectlBinaries}
|
||||
/>
|
||||
<small className="hint">
|
||||
<Trans>Download kubectl binaries matching to Kubernetes cluster verison.</Trans>
|
||||
</small>
|
||||
<SubTitle title="Download mirror" />
|
||||
<Select
|
||||
placeholder={<Trans>Download mirror for kubectl</Trans>}
|
||||
@ -64,20 +66,20 @@ export const KubectlBinaries = observer(({ preferences }: { preferences: UserPre
|
||||
onChange={({ value }: SelectOption) => preferences.downloadMirror = value}
|
||||
disabled={!preferences.downloadKubectlBinaries}
|
||||
/>
|
||||
<SubTitle title="Directory for binaries"/>
|
||||
<SubTitle title="Directory for binaries" />
|
||||
<Input
|
||||
theme="round-black"
|
||||
value={downloadPath}
|
||||
placeholder={`Directory to download binaries into`}
|
||||
placeholder={`Default: ${userStore.getDefaultKubectlPath()}`}
|
||||
validators={isPath}
|
||||
onChange={setDownloadPath}
|
||||
onBlur={save}
|
||||
disabled={!preferences.downloadKubectlBinaries}
|
||||
/>
|
||||
<small>
|
||||
Default: {userStore.getDefaultKubectlPath()}
|
||||
<small className="hint">
|
||||
The directory to download binaries into.
|
||||
</small>
|
||||
{renderPath()}
|
||||
</>
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user