mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
40 lines
1.6 KiB
TypeScript
40 lines
1.6 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 authHeaderValueInjectable from "../../features/auth-header/common/header-value.injectable";
|
|
import { lensAuthHeaderName } from "../../features/auth-header/common/vars";
|
|
import { apiKubePrefix } from "../vars";
|
|
import isDebuggingInjectable from "../vars/is-debugging.injectable";
|
|
import { apiBaseHostHeaderInjectionToken, apiBaseServerAddressInjectionToken } from "./api-base-configs";
|
|
import createKubeJsonApiInjectable from "./create-kube-json-api.injectable";
|
|
import type { KubeJsonApi } from "./kube-json-api";
|
|
|
|
export type CreateKubeJsonApiForCluster = (clusterId: string) => KubeJsonApi;
|
|
|
|
const createKubeJsonApiForClusterInjectable = getInjectable({
|
|
id: "create-kube-json-api-for-cluster",
|
|
instantiate: (di): CreateKubeJsonApiForCluster => {
|
|
const createKubeJsonApi = di.inject(createKubeJsonApiInjectable);
|
|
const isDebugging = di.inject(isDebuggingInjectable);
|
|
const authHeaderValue = di.inject(authHeaderValueInjectable);
|
|
|
|
return (clusterId) => createKubeJsonApi(
|
|
{
|
|
serverAddress: di.inject(apiBaseServerAddressInjectionToken),
|
|
apiBase: apiKubePrefix,
|
|
debug: isDebugging,
|
|
},
|
|
{
|
|
headers: {
|
|
"Host": `${clusterId}.${di.inject(apiBaseHostHeaderInjectionToken)}`,
|
|
[lensAuthHeaderName]: authHeaderValue,
|
|
},
|
|
},
|
|
);
|
|
},
|
|
});
|
|
|
|
export default createKubeJsonApiForClusterInjectable;
|