diff --git a/packages/core/src/common/fetch/fetch-module.injectable.ts b/packages/core/src/common/fetch/fetch-module.injectable.ts deleted file mode 100644 index ba83d8fd82..0000000000 --- a/packages/core/src/common/fetch/fetch-module.injectable.ts +++ /dev/null @@ -1,17 +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 * as NodeFetch from "@k8slens/node-fetch"; - -/** - * NOTE: while using this module can cause side effects, this specific injectable is not marked as - * such since sometimes the request can be wholely within the perview of unit test - */ -const nodeFetchModuleInjectable = getInjectable({ - id: "node-fetch-module", - instantiate: () => NodeFetch, -}); - -export default nodeFetchModuleInjectable; diff --git a/packages/core/src/common/fetch/fetch.injectable.ts b/packages/core/src/common/fetch/fetch.injectable.ts index 860746bb5d..82dd141964 100644 --- a/packages/core/src/common/fetch/fetch.injectable.ts +++ b/packages/core/src/common/fetch/fetch.injectable.ts @@ -4,17 +4,13 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import type { RequestInit, Response } from "@k8slens/node-fetch"; -import nodeFetchModuleInjectable from "./fetch-module.injectable"; +import fetch from "@k8slens/node-fetch"; export type Fetch = (url: string, init?: RequestInit) => Promise; const fetchInjectable = getInjectable({ id: "fetch", - instantiate: (di): Fetch => { - const { default: fetch } = di.inject(nodeFetchModuleInjectable); - - return (url, init) => fetch(url, init); - }, + instantiate: () => fetch as Fetch, causesSideEffects: true, }); diff --git a/packages/core/src/common/fetch/lens-fetch.injectable.ts b/packages/core/src/common/fetch/lens-fetch.injectable.ts index 87db6d4c52..634081fda5 100644 --- a/packages/core/src/common/fetch/lens-fetch.injectable.ts +++ b/packages/core/src/common/fetch/lens-fetch.injectable.ts @@ -7,7 +7,7 @@ import { Agent } from "https"; import type { RequestInit, Response } from "@k8slens/node-fetch"; import lensProxyPortInjectable from "../../main/lens-proxy/lens-proxy-port.injectable"; import lensProxyCertificateInjectable from "../certificate/lens-proxy-certificate.injectable"; -import nodeFetchModuleInjectable from "./fetch-module.injectable"; +import fetch from "@k8slens/node-fetch"; export type LensRequestInit = Omit; @@ -16,7 +16,6 @@ export type LensFetch = (pathnameAndQuery: string, init?: LensRequestInit) => Pr const lensFetchInjectable = getInjectable({ id: "lens-fetch", instantiate: (di): LensFetch => { - const { default: fetch } = di.inject(nodeFetchModuleInjectable); const lensProxyPort = di.inject(lensProxyPortInjectable); const lensProxyCertificate = di.inject(lensProxyCertificateInjectable); diff --git a/packages/core/src/main/get-metrics.injectable.ts b/packages/core/src/main/get-metrics.injectable.ts index 7a17ce3884..3731435f6b 100644 --- a/packages/core/src/main/get-metrics.injectable.ts +++ b/packages/core/src/main/get-metrics.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import type { Cluster } from "../common/cluster/cluster"; -import nodeFetchModuleInjectable from "../common/fetch/fetch-module.injectable"; +import { FormData } from "@k8slens/node-fetch"; import type { RequestMetricsParams } from "../common/k8s-api/endpoints/metrics.api/request-metrics.injectable"; import { object } from "../common/utils"; import k8sRequestInjectable from "./k8s-request.injectable"; @@ -16,7 +16,6 @@ const getMetricsInjectable = getInjectable({ instantiate: (di): GetMetrics => { const k8sRequest = di.inject(k8sRequestInjectable); - const { FormData } = di.inject(nodeFetchModuleInjectable); return async ( cluster,