-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make ResourceStack fully injectable (#6591)
Signed-off-by: Sebastian Malton <sebastian@malton.name> Signed-off-by: Sebastian Malton <sebastian@malton.name>
- Loading branch information
Showing
15 changed files
with
341 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
import { getInjectable } from "@ogre-tools/injectable"; | ||
import type { KubernetesCluster } from "../catalog-entities"; | ||
import readDirectoryInjectable from "../fs/read-directory.injectable"; | ||
import readFileInjectable from "../fs/read-file.injectable"; | ||
import { kubectlApplyAllInjectionToken, kubectlDeleteAllInjectionToken } from "../kube-helpers/channels"; | ||
import loggerInjectable from "../logger.injectable"; | ||
import joinPathsInjectable from "../path/join-paths.injectable"; | ||
import type { ResourceApplyingStack, ResourceStackDependencies } from "./resource-stack"; | ||
import { ResourceStack } from "./resource-stack"; | ||
|
||
export type CreateResourceStack = (cluster: KubernetesCluster, name: string) => ResourceApplyingStack; | ||
|
||
const createResourceStackInjectable = getInjectable({ | ||
id: "create-resource-stack", | ||
instantiate: (di): CreateResourceStack => { | ||
const deps: ResourceStackDependencies = { | ||
joinPaths: di.inject(joinPathsInjectable), | ||
kubectlApplyAll: di.inject(kubectlApplyAllInjectionToken), | ||
kubectlDeleteAll: di.inject(kubectlDeleteAllInjectionToken), | ||
logger: di.inject(loggerInjectable), | ||
readDirectory: di.inject(readDirectoryInjectable), | ||
readFile: di.inject(readFileInjectable), | ||
}; | ||
|
||
return (cluster, name) => new ResourceStack(deps, cluster, name); | ||
}, | ||
}); | ||
|
||
export default createResourceStackInjectable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
|
||
import { getInjectionToken } from "@ogre-tools/injectable"; | ||
import type { Asyncify } from "type-fest"; | ||
import type { RequestChannelHandler } from "../../main/utils/channel/channel-listeners/listener-tokens"; | ||
import type { ClusterId } from "../cluster-types"; | ||
import type { AsyncResult } from "../utils/async-result"; | ||
import type { RequestChannel } from "../utils/channel/request-channel-listener-injection-token"; | ||
|
||
export interface KubectlApplyAllArgs { | ||
clusterId: ClusterId; | ||
resources: string[]; | ||
extraArgs: string[]; | ||
} | ||
|
||
export const kubectlApplyAllChannel: RequestChannel<KubectlApplyAllArgs, AsyncResult<string, string>> = { | ||
id: "kubectl-apply-all", | ||
}; | ||
|
||
export type KubectlApplyAll = Asyncify<RequestChannelHandler<typeof kubectlApplyAllChannel>>; | ||
|
||
export const kubectlApplyAllInjectionToken = getInjectionToken<KubectlApplyAll>({ | ||
id: "kubectl-apply-all", | ||
}); | ||
|
||
export interface KubectlDeleteAllArgs { | ||
clusterId: ClusterId; | ||
resources: string[]; | ||
extraArgs: string[]; | ||
} | ||
|
||
export const kubectlDeleteAllChannel: RequestChannel<KubectlDeleteAllArgs, AsyncResult<string, string>> = { | ||
id: "kubectl-delete-all", | ||
}; | ||
|
||
export type KubectlDeleteAll = Asyncify<RequestChannelHandler<typeof kubectlDeleteAllChannel>>; | ||
|
||
export const kubectlDeleteAllInjectionToken = getInjectionToken<KubectlDeleteAll>({ | ||
id: "kubectl-delete-all", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.