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:
parent
eecf2b1899
commit
34974208a5
@ -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;
|
|
||||||
@ -4,17 +4,13 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import type { RequestInit, Response } from "@k8slens/node-fetch";
|
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>;
|
export type Fetch = (url: string, init?: RequestInit) => Promise<Response>;
|
||||||
|
|
||||||
const fetchInjectable = getInjectable({
|
const fetchInjectable = getInjectable({
|
||||||
id: "fetch",
|
id: "fetch",
|
||||||
instantiate: (di): Fetch => {
|
instantiate: () => fetch as Fetch,
|
||||||
const { default: fetch } = di.inject(nodeFetchModuleInjectable);
|
|
||||||
|
|
||||||
return (url, init) => fetch(url, init);
|
|
||||||
},
|
|
||||||
causesSideEffects: true,
|
causesSideEffects: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import { Agent } from "https";
|
|||||||
import type { RequestInit, Response } from "@k8slens/node-fetch";
|
import type { RequestInit, Response } from "@k8slens/node-fetch";
|
||||||
import lensProxyPortInjectable from "../../main/lens-proxy/lens-proxy-port.injectable";
|
import lensProxyPortInjectable from "../../main/lens-proxy/lens-proxy-port.injectable";
|
||||||
import lensProxyCertificateInjectable from "../certificate/lens-proxy-certificate.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">;
|
export type LensRequestInit = Omit<RequestInit, "agent">;
|
||||||
|
|
||||||
@ -16,7 +16,6 @@ export type LensFetch = (pathnameAndQuery: string, init?: LensRequestInit) => Pr
|
|||||||
const lensFetchInjectable = getInjectable({
|
const lensFetchInjectable = getInjectable({
|
||||||
id: "lens-fetch",
|
id: "lens-fetch",
|
||||||
instantiate: (di): LensFetch => {
|
instantiate: (di): LensFetch => {
|
||||||
const { default: fetch } = di.inject(nodeFetchModuleInjectable);
|
|
||||||
const lensProxyPort = di.inject(lensProxyPortInjectable);
|
const lensProxyPort = di.inject(lensProxyPortInjectable);
|
||||||
const lensProxyCertificate = di.inject(lensProxyCertificateInjectable);
|
const lensProxyCertificate = di.inject(lensProxyCertificateInjectable);
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import type { Cluster } from "../common/cluster/cluster";
|
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 type { RequestMetricsParams } from "../common/k8s-api/endpoints/metrics.api/request-metrics.injectable";
|
||||||
import { object } from "../common/utils";
|
import { object } from "../common/utils";
|
||||||
import k8sRequestInjectable from "./k8s-request.injectable";
|
import k8sRequestInjectable from "./k8s-request.injectable";
|
||||||
@ -16,7 +16,6 @@ const getMetricsInjectable = getInjectable({
|
|||||||
|
|
||||||
instantiate: (di): GetMetrics => {
|
instantiate: (di): GetMetrics => {
|
||||||
const k8sRequest = di.inject(k8sRequestInjectable);
|
const k8sRequest = di.inject(k8sRequestInjectable);
|
||||||
const { FormData } = di.inject(nodeFetchModuleInjectable);
|
|
||||||
|
|
||||||
return async (
|
return async (
|
||||||
cluster,
|
cluster,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user