fix circular dependency

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton committed 2022-03-17 09:30:10 -04:00
1 parent fd223b130f
commit 08e4e7d59d
4 files changed
+25 -24

No files matched your search

@@ -4,13 +4,10 @@
*/
import { JsonApi } from "./json-api";
import { KubeJsonApi } from "./kube-json-api";
import { apiKubePrefix, apiPrefix, isDebugging, isDevelopment } from "../../common/vars";
import { isClusterPageContext } from "../utils/cluster-id-url-parsing";
import { apiPrefix, isDebugging, isDevelopment } from "../vars";
import { appEventBus } from "../app-event-bus/event-bus";
let apiBase: JsonApi;
let apiKube: KubeJsonApi;
export let apiBase: JsonApi;
if (typeof window === "undefined") {
appEventBus.addListener((event) => {
@@ -41,20 +38,3 @@ if (typeof window === "undefined") {
},
});
}
if (isClusterPageContext()) {
apiKube = new KubeJsonApi({
serverAddress: `http://127.0.0.1:${window.location.port}`,
apiBase: apiKubePrefix,
debug: isDevelopment,
}, {
headers: {
"Host": window.location.host,
},
});
}
export {
apiBase,
apiKube,
};
+20
View File
@@ -0,0 +1,20 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { isClusterPageContext } from "../utils";
import { KubeJsonApi } from "./kube-json-api";
import { apiKubePrefix, isDevelopment } from "../vars";
export const apiKube = isClusterPageContext()
? new KubeJsonApi({
serverAddress: `http://127.0.0.1:${window.location.port}`,
apiBase: apiKubePrefix,
debug: isDevelopment,
}, {
headers: {
"Host": window.location.host,
},
})
: null;
+2 -1
View File
@@ -3,4 +3,5 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
export { apiBase, apiKube } from "./apis";
export { apiBase } from "./api-base";
export { apiKube } from "./api-kube";
+1 -1
View File
@@ -6,7 +6,7 @@
import { JsonApi, JsonApiData, JsonApiError } from "./json-api";
import type { Response } from "node-fetch";
import { apiKubePrefix, isDebugging } from "../vars";
import { apiBase } from "./apis";
import { apiBase } from "./api-base";
export interface KubeJsonApiListMetadata {
resourceVersion: string;