1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Remove unnecessary fetchModuleInjectable

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2023-01-25 09:06:37 -05:00
parent eecf2b1899
commit 34974208a5
4 changed files with 4 additions and 27 deletions

View File

@ -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;

View File

@ -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<Response>;
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,
});

View File

@ -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<RequestInit, "agent">;
@ -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);

View File

@ -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,