diff --git a/src/common/k8s-api/endpoints/deployment.api.ts b/src/common/k8s-api/endpoints/deployment.api.ts index 51d79572ec..c877669ba4 100644 --- a/src/common/k8s-api/endpoints/deployment.api.ts +++ b/src/common/k8s-api/endpoints/deployment.api.ts @@ -93,8 +93,8 @@ export interface DeploymentSpec { template: { metadata: { creationTimestamp?: string; - labels: Record; - annotations?: Record; + labels: Partial>; + annotations?: Partial>; }; spec: PodSpec; }; diff --git a/src/common/k8s-api/endpoints/horizontal-pod-autoscaler.api.ts b/src/common/k8s-api/endpoints/horizontal-pod-autoscaler.api.ts index 96998e8656..06d5669220 100644 --- a/src/common/k8s-api/endpoints/horizontal-pod-autoscaler.api.ts +++ b/src/common/k8s-api/endpoints/horizontal-pod-autoscaler.api.ts @@ -93,8 +93,8 @@ export interface HorizontalPodAutoscalerStatus { } interface MetricCurrentTarget { - current?: string | undefined; - target?: string | undefined; + current?: string; + target?: string; } export class HorizontalPodAutoscaler extends KubeObject { diff --git a/src/common/k8s-api/endpoints/pod.api.ts b/src/common/k8s-api/endpoints/pod.api.ts index 9a0cff65ef..7b0bf55e9e 100644 --- a/src/common/k8s-api/endpoints/pod.api.ts +++ b/src/common/k8s-api/endpoints/pod.api.ts @@ -713,8 +713,8 @@ export interface PodSpec { imagePullSecrets?: LocalObjectReference[]; initContainers?: PodContainer[]; nodeName?: string; - nodeSelector?: Record; - overhead?: Record; + nodeSelector?: Partial>; + overhead?: Partial>; preemptionPolicy?: string; priority?: number; priorityClassName?: string; diff --git a/src/common/k8s-api/json-api.ts b/src/common/k8s-api/json-api.ts index a940b0e02d..36b4fdd9f5 100644 --- a/src/common/k8s-api/json-api.ts +++ b/src/common/k8s-api/json-api.ts @@ -84,7 +84,7 @@ export class JsonApi = Js async getResponse( path: string, - params?: ParamsAndQuery | undefined, + params?: ParamsAndQuery, init: RequestInit = {}, ): Promise { let reqUrl = `${this.config.serverAddress}${this.config.apiBase}${path}`; @@ -110,7 +110,7 @@ export class JsonApi = Js get( path: string, - params?: ParamsAndQuery | undefined, + params?: ParamsAndQuery, reqInit: RequestInit = {}, ) { return this.request(path, params, { ...reqInit, method: "get" }); @@ -118,7 +118,7 @@ export class JsonApi = Js post( path: string, - params?: ParamsAndQuery | undefined, + params?: ParamsAndQuery, reqInit: RequestInit = {}, ) { return this.request(path, params, { ...reqInit, method: "post" }); @@ -126,7 +126,7 @@ export class JsonApi = Js put( path: string, - params?: ParamsAndQuery | undefined, + params?: ParamsAndQuery, reqInit: RequestInit = {}, ) { return this.request(path, params, { ...reqInit, method: "put" }); @@ -134,7 +134,7 @@ export class JsonApi = Js patch( path: string, - params?: (ParamsAndQuery, Query> & { data?: Patch | PartialDeep }) | undefined, + params?: (ParamsAndQuery, Query> & { data?: Patch | PartialDeep }), reqInit: RequestInit = {}, ) { return this.request(path, params, { ...reqInit, method: "patch" }); @@ -142,7 +142,7 @@ export class JsonApi = Js del( path: string, - params?: ParamsAndQuery | undefined, + params?: ParamsAndQuery, reqInit: RequestInit = {}, ) { return this.request(path, params, { ...reqInit, method: "delete" }); diff --git a/src/common/k8s-api/kube-api-parse.ts b/src/common/k8s-api/kube-api-parse.ts index 5be50b79f6..509f1c28e9 100644 --- a/src/common/k8s-api/kube-api-parse.ts +++ b/src/common/k8s-api/kube-api-parse.ts @@ -8,11 +8,11 @@ import { splitArray } from "../utils"; export interface IKubeApiLinkRef { - apiPrefix?: string | undefined; + apiPrefix?: string; apiVersion: string; resource: string; - name?: string | undefined; - namespace?: string | undefined; + name?: string; + namespace?: string; } export interface IKubeApiParsed extends IKubeApiLinkRef { diff --git a/src/common/k8s-api/kube-api.ts b/src/common/k8s-api/kube-api.ts index bc7aa3b19a..d7e82d1b38 100644 --- a/src/common/k8s-api/kube-api.ts +++ b/src/common/k8s-api/kube-api.ts @@ -105,18 +105,18 @@ export interface IgnoredKubeApiOptions { } export interface KubeApiQueryParams { - watch?: boolean | number | undefined; - resourceVersion?: string | undefined; - timeoutSeconds?: number | undefined; - limit?: number | undefined; // doesn't work with ?watch - continue?: string | undefined; // might be used with ?limit from second request - labelSelector?: string | string[] | undefined; // restrict list of objects by their labels, e.g. labelSelector: ["label=value"] - fieldSelector?: string | string[] | undefined; // restrict list of objects by their fields, e.g. fieldSelector: "field=name" + watch?: boolean | number; + resourceVersion?: string; + timeoutSeconds?: number; + limit?: number; // doesn't work with ?watch + continue?: string; // might be used with ?limit from second request + labelSelector?: string | string[]; // restrict list of objects by their labels, e.g. labelSelector: ["label=value"] + fieldSelector?: string | string[]; // restrict list of objects by their fields, e.g. fieldSelector: "field=name" } export interface KubeApiListOptions { - namespace?: string | undefined; - reqInit?: RequestInit | undefined; + namespace?: string; + reqInit?: RequestInit; } export interface IKubePreferredVersion { @@ -268,13 +268,13 @@ export type KubeApiWatchCallback = export interface KubeApiWatchOptions, Data extends KubeJsonApiDataFor> { namespace: string; - callback?: KubeApiWatchCallback | undefined; - abortController?: AbortController | undefined; - watchId?: string | undefined; - retry?: boolean | undefined; + callback?: KubeApiWatchCallback; + abortController?: AbortController; + watchId?: string; + retry?: boolean; // timeout in seconds - timeout?: number | undefined; + timeout?: number; } export type KubeApiPatchType = "merge" | "json" | "strategic"; @@ -296,7 +296,7 @@ export interface ResourceDescriptor { * * Note: if not provided and the resource kind is namespaced, then this defaults to `"default"` */ - namespace?: string | undefined; + namespace?: string; } export interface DeleteResourceDescriptor extends ResourceDescriptor { @@ -559,7 +559,7 @@ export class KubeApi< return null; } - private ensureMetadataSelfLink(metadata: T): asserts metadata is T & { selfLink: string } { + private ensureMetadataSelfLink(metadata: T): asserts metadata is T & { selfLink: string } { metadata.selfLink ||= createKubeApiURL({ apiPrefix: this.apiPrefix, apiVersion: this.apiVersionWithGroup, diff --git a/src/common/k8s-api/kube-object.store.ts b/src/common/k8s-api/kube-object.store.ts index 3fd302163b..58502a3097 100644 --- a/src/common/k8s-api/kube-object.store.ts +++ b/src/common/k8s-api/kube-object.store.ts @@ -26,13 +26,13 @@ export type OnLoadFailure = (error: unknown) => void; export interface KubeObjectStoreLoadingParams { namespaces: string[]; - reqInit?: RequestInit | undefined; + reqInit?: RequestInit; /** * A function that is called when listing fails. If set then blocks errors * being rejected with */ - onLoadFailure?: OnLoadFailure | undefined; + onLoadFailure?: OnLoadFailure; } export interface KubeObjectStoreLoadAllParams { @@ -44,7 +44,7 @@ export interface KubeObjectStoreLoadAllParams { * A function that is called when listing fails. If set then blocks errors * being rejected with */ - onLoadFailure?: OnLoadFailure | undefined; + onLoadFailure?: OnLoadFailure; } export interface KubeObjectStoreSubscribeParams { @@ -52,7 +52,7 @@ export interface KubeObjectStoreSubscribeParams { * A function that is called when listing fails. If set then blocks errors * being rejected with */ - onLoadFailure?: OnLoadFailure | undefined; + onLoadFailure?: OnLoadFailure; /** * An optional parent abort controller diff --git a/src/common/k8s-api/kube-object.ts b/src/common/k8s-api/kube-object.ts index ff5ec2ae38..ce66fd6e84 100644 --- a/src/common/k8s-api/kube-object.ts +++ b/src/common/k8s-api/kube-object.ts @@ -354,7 +354,7 @@ export interface Affinity { } export interface LabelSelector { - matchLabels?: Record; + matchLabels?: Partial>; matchExpressions?: LabelMatchExpression[]; } @@ -465,7 +465,7 @@ export class KubeObject< ); } - static stringifyLabels(labels?: Record): string[] { + static stringifyLabels(labels?: Partial>): string[] { if (!labels) return []; return Object.entries(labels).map(([name, value]) => `${name}=${value}`); diff --git a/src/renderer/components/+catalog/get-label-badges.injectable.tsx b/src/renderer/components/+catalog/get-label-badges.injectable.tsx index 516a192f4c..b75e501f90 100644 --- a/src/renderer/components/+catalog/get-label-badges.injectable.tsx +++ b/src/renderer/components/+catalog/get-label-badges.injectable.tsx @@ -10,7 +10,7 @@ import searchUrlPageParamInjectable from "../input/search-url-page-param.injecta import { KubeObject } from "../../../common/k8s-api/kube-object"; import { Badge } from "../badge"; -export type GetLabelBadges = (entity: CatalogEntity, onClick?: ((evt: React.MouseEvent) => void) | undefined) => JSX.Element[]; +export type GetLabelBadges = (entity: CatalogEntity, onClick?: (evt: React.MouseEvent) => void) => JSX.Element[]; const getLabelBadgesInjectable = getInjectable({ id: "get-label-badges", diff --git a/src/renderer/components/input/input_validators.ts b/src/renderer/components/input/input_validators.ts index 85b532e62f..4c0befbd29 100644 --- a/src/renderer/components/input/input_validators.ts +++ b/src/renderer/components/input/input_validators.ts @@ -83,7 +83,7 @@ export const isUrl = inputValidator({ */ export const isExtensionNameInstallRegex = TypedRegEx("^(?(@[-\\w]+\\/)?[-\\w]+)(@(?[a-z0-9-_.]+))?$", "gi") as { isMatch(val: string): boolean; - captures(val: string): undefined | { name: string; version?: string | undefined }; + captures(val: string): undefined | { name: string; version?: string }; }; export const isExtensionNameInstall = inputValidator({ diff --git a/src/renderer/components/test-utils/get-application-builder.tsx b/src/renderer/components/test-utils/get-application-builder.tsx index 9b43d8b0ea..2fd9c9f000 100644 --- a/src/renderer/components/test-utils/get-application-builder.tsx +++ b/src/renderer/components/test-utils/get-application-builder.tsx @@ -72,7 +72,6 @@ interface Environment { export const getApplicationBuilder = () => { const { rendererDi, mainDi, runSetups } = getDisForUnitTesting({ doGeneralOverrides: true, - overrideCreateStorage: false, }); const dis = { rendererDi, mainDi }; diff --git a/src/test-utils/get-dis-for-unit-testing.ts b/src/test-utils/get-dis-for-unit-testing.ts index 9a41cf97cd..9141350180 100644 --- a/src/test-utils/get-dis-for-unit-testing.ts +++ b/src/test-utils/get-dis-for-unit-testing.ts @@ -2,9 +2,7 @@ * Copyright (c) OpenLens Authors. All rights reserved. * Licensed under MIT License. See LICENSE in root directory for more information. */ -import type { GetRendererDiForUnitTestingOptions } from "../renderer/getDiForUnitTesting"; import { getDiForUnitTesting as getRendererDi } from "../renderer/getDiForUnitTesting"; -import type { GetMainDiForUnitTestingOptions } from "../main/getDiForUnitTesting"; import { getDiForUnitTesting as getMainDi } from "../main/getDiForUnitTesting"; import { overrideIpcBridge } from "./override-ipc-bridge"; @@ -12,7 +10,7 @@ export interface GetDiForUnitTestingOptions { doGeneralOverrides?: boolean; } -export const getDisForUnitTesting = (opts?: GetMainDiForUnitTestingOptions & GetRendererDiForUnitTestingOptions) => { +export const getDisForUnitTesting = (opts?: GetDiForUnitTestingOptions) => { const rendererDi = getRendererDi(opts); const mainDi = getMainDi(opts);