1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/main/context-handler/create-context-handler.injectable.ts
Sebastian Malton 203580ad92 fix delete-cluster-dialog.test.tsx
Signed-off-by: Sebastian Malton <sebastian@malton.name>
2022-05-04 08:46:41 -04:00

35 lines
1.2 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 selfsigned from "selfsigned";
import type { Cluster } from "../../common/cluster/cluster";
import type { ClusterContextHandler } from "./context-handler";
import { ContextHandler } from "./context-handler";
import createKubeAuthProxyInjectable from "../kube-auth-proxy/create-kube-auth-proxy.injectable";
import { getKubeAuthProxyCertificate } from "../kube-auth-proxy/get-kube-auth-proxy-certificate";
import URLParse from "url-parse";
const createContextHandlerInjectable = getInjectable({
id: "create-context-handler",
instantiate: (di) => {
const createKubeAuthProxy = di.inject(createKubeAuthProxyInjectable);
return (cluster: Cluster): ClusterContextHandler | undefined => {
const clusterUrl = new URLParse(cluster.apiUrl);
return new ContextHandler(
{
createKubeAuthProxy,
authProxyCa: getKubeAuthProxyCertificate(clusterUrl.hostname, selfsigned.generate).cert,
},
cluster,
);
};
},
});
export default createContextHandlerInjectable;