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
Jari Kolehmainen 5176970438 more dependencies
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
2022-03-10 15:59:47 +02:00

32 lines
1.3 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 { KubeAuthProxy, KubeAuthProxyDependencies } from "./kube-auth-proxy";
import { spawn } from "child_process";
import type { Cluster } from "../../common/cluster/cluster";
import path from "path";
import { getBinaryName } from "../../common/vars";
import directoryForBundledBinariesInjectable from "../../common/app-paths/directory-for-bundled-binaries/directory-for-bundled-binaries.injectable";
import getKubeAuthProxyCertDirInjectable from "./kube-auth-proxy-cert.injectable";
const createKubeAuthProxyInjectable = getInjectable({
id: "create-kube-auth-proxy",
instantiate: (di) => {
const binaryName = getBinaryName("lens-k8s-proxy");
const dependencies: KubeAuthProxyDependencies = {
proxyBinPath: path.join(di.inject(directoryForBundledBinariesInjectable), binaryName),
proxyCertPath: di.inject(getKubeAuthProxyCertDirInjectable),
spawn,
};
return (cluster: Cluster, environmentVariables: NodeJS.ProcessEnv) => (
new KubeAuthProxy(dependencies, cluster, environmentVariables)
);
},
});
export default createKubeAuthProxyInjectable;