mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Convert DirectoryForKubectlBinaries to LazyInitializableState
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
a7b928d467
commit
9276cdff76
@ -2,13 +2,12 @@
|
|||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import directoryForBinariesInjectable from "../directory-for-binaries.injectable";
|
import directoryForBinariesInjectable from "./directory-for-binaries.injectable";
|
||||||
import joinPathsInjectable from "../../path/join-paths.injectable";
|
import { createLazyInitializableState } from "../initializable-state/create-lazy";
|
||||||
import { createLazyInitializableState } from "../../initializable-state/create-lazy";
|
import joinPathsInjectable from "../path/join-paths.injectable";
|
||||||
|
|
||||||
const directoryForKubectlBinariesInjectable = createLazyInitializableState({
|
const directoryForKubectlBinariesInjectable = createLazyInitializableState({
|
||||||
id: "directory-for-kubectl-binaries",
|
id: "directory-for-kubectl-binaries",
|
||||||
|
|
||||||
init: (di) => {
|
init: (di) => {
|
||||||
const joinPaths = di.inject(joinPathsInjectable);
|
const joinPaths = di.inject(joinPathsInjectable);
|
||||||
const directoryForBinaries = di.inject(directoryForBinariesInjectable);
|
const directoryForBinaries = di.inject(directoryForBinariesInjectable);
|
||||||
@ -9,11 +9,12 @@ import type { UserStore } from "../../../../../../../common/user-store";
|
|||||||
import userStoreInjectable from "../../../../../../../common/user-store/user-store.injectable";
|
import userStoreInjectable from "../../../../../../../common/user-store/user-store.injectable";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { Input, InputValidators } from "../../../../../../../renderer/components/input";
|
import { Input, InputValidators } from "../../../../../../../renderer/components/input";
|
||||||
import directoryForKubectlBinariesInjectable from "../../../../../../../common/app-paths/directory-for-kubectl-binaries/directory-for-kubectl-binaries.injectable";
|
import directoryForKubectlBinariesInjectable from "../../../../../../../common/app-paths/directory-for-kubectl-binaries.injectable";
|
||||||
|
import type { LazyInitializableState } from "../../../../../../../common/initializable-state/create-lazy";
|
||||||
|
|
||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
userStore: UserStore;
|
userStore: UserStore;
|
||||||
defaultPathForKubectlBinaries: string;
|
defaultPathForKubectlBinaries: LazyInitializableState<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const NonInjectedKubectlPathToBinary = observer(
|
const NonInjectedKubectlPathToBinary = observer(
|
||||||
@ -30,7 +31,7 @@ const NonInjectedKubectlPathToBinary = observer(
|
|||||||
<SubTitle title="Path to kubectl binary" />
|
<SubTitle title="Path to kubectl binary" />
|
||||||
<Input
|
<Input
|
||||||
theme="round-black"
|
theme="round-black"
|
||||||
placeholder={defaultPathForKubectlBinaries}
|
placeholder={defaultPathForKubectlBinaries.get()}
|
||||||
value={binariesPath}
|
value={binariesPath}
|
||||||
validators={pathValidator}
|
validators={pathValidator}
|
||||||
onChange={setBinariesPath}
|
onChange={setBinariesPath}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import type { KubectlDependencies } from "./kubectl";
|
import type { KubectlDependencies } from "./kubectl";
|
||||||
import { Kubectl } from "./kubectl";
|
import { Kubectl } from "./kubectl";
|
||||||
import directoryForKubectlBinariesInjectable from "../../common/app-paths/directory-for-kubectl-binaries/directory-for-kubectl-binaries.injectable";
|
import directoryForKubectlBinariesInjectable from "../../common/app-paths/directory-for-kubectl-binaries.injectable";
|
||||||
import userStoreInjectable from "../../common/user-store/user-store.injectable";
|
import userStoreInjectable from "../../common/user-store/user-store.injectable";
|
||||||
import kubectlDownloadingNormalizedArchInjectable from "./normalized-arch.injectable";
|
import kubectlDownloadingNormalizedArchInjectable from "./normalized-arch.injectable";
|
||||||
import normalizedPlatformInjectable from "../../common/vars/normalized-platform.injectable";
|
import normalizedPlatformInjectable from "../../common/vars/normalized-platform.injectable";
|
||||||
|
|||||||
@ -17,11 +17,12 @@ import { noop } from "lodash/fp";
|
|||||||
import type { JoinPaths } from "../../common/path/join-paths.injectable";
|
import type { JoinPaths } from "../../common/path/join-paths.injectable";
|
||||||
import type { GetDirnameOfPath } from "../../common/path/get-dirname.injectable";
|
import type { GetDirnameOfPath } from "../../common/path/get-dirname.injectable";
|
||||||
import type { GetBasenameOfPath } from "../../common/path/get-basename.injectable";
|
import type { GetBasenameOfPath } from "../../common/path/get-basename.injectable";
|
||||||
|
import type { LazyInitializableState } from "../../common/initializable-state/create-lazy";
|
||||||
|
|
||||||
const initScriptVersionString = "# lens-initscript v3";
|
const initScriptVersionString = "# lens-initscript v3";
|
||||||
|
|
||||||
export interface KubectlDependencies {
|
export interface KubectlDependencies {
|
||||||
readonly directoryForKubectlBinaries: string;
|
readonly directoryForKubectlBinaries: LazyInitializableState<string>;
|
||||||
readonly normalizedDownloadPlatform: "darwin" | "linux" | "windows";
|
readonly normalizedDownloadPlatform: "darwin" | "linux" | "windows";
|
||||||
readonly normalizedDownloadArch: "amd64" | "arm64" | "386";
|
readonly normalizedDownloadArch: "amd64" | "arm64" | "386";
|
||||||
readonly kubectlBinaryName: string;
|
readonly kubectlBinaryName: string;
|
||||||
@ -88,12 +89,12 @@ export class Kubectl {
|
|||||||
return this.dependencies.userStore.kubectlBinariesPath || this.getBundledPath();
|
return this.dependencies.userStore.kubectlBinariesPath || this.getBundledPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getDownloadDir() {
|
protected getDownloadDir(): string {
|
||||||
if (this.dependencies.userStore.downloadBinariesPath) {
|
if (this.dependencies.userStore.downloadBinariesPath) {
|
||||||
return this.dependencies.joinPaths(this.dependencies.userStore.downloadBinariesPath, "kubectl");
|
return this.dependencies.joinPaths(this.dependencies.userStore.downloadBinariesPath, "kubectl");
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.dependencies.directoryForKubectlBinaries;
|
return this.dependencies.directoryForKubectlBinaries.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public getPath = async (bundled = false): Promise<string> => {
|
public getPath = async (bundled = false): Promise<string> => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user