mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Make apiBase not an InjectionToken and make openNodeShellSession not special (#6774)
* Replace apiBaseInjectionToken with tokens for configuration instead Signed-off-by: Sebastian Malton <sebastian@malton.name> * Use new ordering to make openNodeShellSession non-special Signed-off-by: Sebastian Malton <sebastian@malton.name> Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
de789ff955
commit
5c6402b60a
33 files changed
+175
-133
No files matched your search
+1
-1
@@ -3,9 +3,9 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import apiBaseInjectable from "../../../common/k8s-api/api-base.injectable";
|
||||
import type { ServiceAccount } from "../../../common/k8s-api/endpoints";
|
||||
import { urlBuilderFor } from "../../../common/utils/buildUrl";
|
||||
import apiBaseInjectable from "../../k8s/api-base.injectable";
|
||||
import openKubeconfigDialogInjectable from "./open.injectable";
|
||||
|
||||
export type OpenServiceAccountKubeConfigDialog = (account: ServiceAccount) => void;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* 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 { apiBaseHostHeaderInjectionToken } from "../../common/k8s-api/api-base-configs";
|
||||
import windowLocationInjectable from "../../common/k8s-api/window-location.injectable";
|
||||
|
||||
const apiBaseHostHeaderInjectable = getInjectable({
|
||||
id: "api-base-host-header",
|
||||
instantiate: (di) => di.inject(windowLocationInjectable).host,
|
||||
injectionToken: apiBaseHostHeaderInjectionToken,
|
||||
});
|
||||
|
||||
export default apiBaseHostHeaderInjectable;
|
||||
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* 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 { apiBaseServerAddressInjectionToken } from "../../common/k8s-api/api-base-configs";
|
||||
import windowLocationInjectable from "../../common/k8s-api/window-location.injectable";
|
||||
|
||||
const apiBaseServerAddressInjectable = getInjectable({
|
||||
id: "api-base-server-address",
|
||||
instantiate: (di) => {
|
||||
const { port } = di.inject(windowLocationInjectable);
|
||||
|
||||
return `http://127.0.0.1:${port}`;
|
||||
},
|
||||
injectionToken: apiBaseServerAddressInjectionToken,
|
||||
});
|
||||
|
||||
export default apiBaseServerAddressInjectable;
|
||||
@@ -1,36 +0,0 @@
|
||||
/**
|
||||
* 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 { apiBaseInjectionToken } from "../../common/k8s-api/api-base";
|
||||
import createJsonApiInjectable from "../../common/k8s-api/create-json-api.injectable";
|
||||
import windowLocationInjectable from "../../common/k8s-api/window-location.injectable";
|
||||
import { apiPrefix } from "../../common/vars";
|
||||
import isDebuggingInjectable from "../../common/vars/is-debugging.injectable";
|
||||
import isDevelopmentInjectable from "../../common/vars/is-development.injectable";
|
||||
|
||||
const apiBaseInjectable = getInjectable({
|
||||
id: "api-base",
|
||||
instantiate: (di) => {
|
||||
const createJsonApi = di.inject(createJsonApiInjectable);
|
||||
const isDebugging = di.inject(isDebuggingInjectable);
|
||||
const { port, host } = di.inject(windowLocationInjectable);
|
||||
|
||||
return createJsonApi(
|
||||
{
|
||||
serverAddress: `http://127.0.0.1:${port}`,
|
||||
apiBase: apiPrefix,
|
||||
debug: di.inject(isDevelopmentInjectable) || isDebugging,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
"Host": host,
|
||||
},
|
||||
},
|
||||
);
|
||||
},
|
||||
injectionToken: apiBaseInjectionToken,
|
||||
});
|
||||
|
||||
export default apiBaseInjectable;
|
||||
@@ -7,8 +7,8 @@ import { PortForwardStore } from "./port-forward-store";
|
||||
import type { ForwardedPort } from "../port-forward-item";
|
||||
import createStorageInjectable from "../../utils/create-storage/create-storage.injectable";
|
||||
import notifyErrorPortForwardingInjectable from "../notify-error-port-forwarding.injectable";
|
||||
import { apiBaseInjectionToken } from "../../../common/k8s-api/api-base";
|
||||
import requestActivePortForwardInjectable from "./request-active-port-forward.injectable";
|
||||
import apiBaseInjectable from "../../../common/k8s-api/api-base.injectable";
|
||||
|
||||
const portForwardStoreInjectable = getInjectable({
|
||||
id: "port-forward-store",
|
||||
@@ -22,7 +22,7 @@ const portForwardStoreInjectable = getInjectable({
|
||||
undefined,
|
||||
),
|
||||
notifyErrorPortForwarding: di.inject(notifyErrorPortForwardingInjectable),
|
||||
apiBase: di.inject(apiBaseInjectionToken),
|
||||
apiBase: di.inject(apiBaseInjectable),
|
||||
requestActivePortForward: di.inject(requestActivePortForwardInjectable),
|
||||
});
|
||||
},
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { apiBaseInjectionToken } from "../../../common/k8s-api/api-base";
|
||||
import apiBaseInjectable from "../../../common/k8s-api/api-base.injectable";
|
||||
import loggerInjectable from "../../../common/logger.injectable";
|
||||
import { urlBuilderFor } from "../../../common/utils/buildUrl";
|
||||
import type { ForwardedPort } from "../port-forward-item";
|
||||
@@ -16,7 +16,7 @@ const requestActiveEndpoint = urlBuilderFor("/pods/port-forward/:namespace/:kind
|
||||
const requestActivePortForwardInjectable = getInjectable({
|
||||
id: "request-active-port-forward",
|
||||
instantiate: (di): RequestActivePortForward => {
|
||||
const apiBase = di.inject(apiBaseInjectionToken);
|
||||
const apiBase = di.inject(apiBaseInjectable);
|
||||
const logger = di.inject(loggerInjectable);
|
||||
|
||||
return async ({ port, forwardPort, namespace, kind, name, ...rest }) => {
|
||||
|
||||
Reference in new issue
Block a user