1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/main/kube-auth-proxy/create-kube-auth-proxy.injectable.ts
Sebastian Malton 286e6c8de7
Make PrometheusProviderRegistry fully injectable (#6592)
* Stop using source code in build file

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Add new injectable version of binaryName

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Add new NormalizedPlatform type

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Switch legacy execHelm to use legacy global DI for binaryPath

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Remove dead code

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Introduce injectable for kube auth proxy certs

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Introduce injectable forms of PrometheusProviders

- Remove class requirement
- Make everything injectable

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Update tests to not use private functions

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Cleanup creating binary names and paths

Signed-off-by: Sebastian Malton <sebastian@malton.name>

Signed-off-by: Sebastian Malton <sebastian@malton.name>
2022-11-25 09:19:57 -05:00

40 lines
1.7 KiB
TypeScript

/**
* 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 { KubeAuthProxyDependencies } from "./kube-auth-proxy";
import { KubeAuthProxy } from "./kube-auth-proxy";
import type { Cluster } from "../../common/cluster/cluster";
import spawnInjectable from "../child-process/spawn.injectable";
import kubeAuthProxyCertificateInjectable from "./kube-auth-proxy-certificate.injectable";
import loggerInjectable from "../../common/logger.injectable";
import waitUntilPortIsUsedInjectable from "./wait-until-port-is-used/wait-until-port-is-used.injectable";
import lensK8sProxyPathInjectable from "./lens-k8s-proxy-path.injectable";
export type CreateKubeAuthProxy = (cluster: Cluster, environmentVariables: NodeJS.ProcessEnv) => KubeAuthProxy;
const createKubeAuthProxyInjectable = getInjectable({
id: "create-kube-auth-proxy",
instantiate: (di): CreateKubeAuthProxy => {
const dependencies: Omit<KubeAuthProxyDependencies, "proxyCert"> = {
proxyBinPath: di.inject(lensK8sProxyPathInjectable),
spawn: di.inject(spawnInjectable),
logger: di.inject(loggerInjectable),
waitUntilPortIsUsed: di.inject(waitUntilPortIsUsedInjectable),
};
return (cluster: Cluster, environmentVariables: NodeJS.ProcessEnv) => {
const clusterUrl = new URL(cluster.apiUrl);
return new KubeAuthProxy({
...dependencies,
proxyCert: di.inject(kubeAuthProxyCertificateInjectable, clusterUrl.hostname),
}, cluster, environmentVariables);
};
},
});
export default createKubeAuthProxyInjectable;