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:
Sebastian Malton authored and GitHub committed 2022-12-16 16:13:57 -05:00
1 parent de789ff955
commit 5c6402b60a
33 files changed
+175 -133

No files matched your search

@@ -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;
-36
View File
@@ -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;