diff --git a/.eslintrc.js b/.eslintrc.js index 1426f74e7f..93e11c414b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -59,6 +59,11 @@ module.exports = { "SwitchCase": 1, }], "no-unused-vars": "off", + "space-before-function-paren": ["error", { + "anonymous": "always", + "named": "never", + "asyncArrow": "always", + }], "unused-imports/no-unused-imports": "error", "unused-imports/no-unused-vars": [ "warn", { @@ -71,12 +76,17 @@ module.exports = { "avoidEscape": true, "allowTemplateLiterals": true, }], + "object-curly-spacing": ["error", "always", { + "objectsInObjects": false, + "arraysInObjects": true, + }], "linebreak-style": ["error", "unix"], "eol-last": ["error", "always"], "semi": ["error", "always"], "object-shorthand": "error", "prefer-template": "error", "template-curly-spacing": "error", + "no-unused-expressions": "error", "padding-line-between-statements": [ "error", { "blankLine": "always", "prev": "*", "next": "return" }, @@ -84,8 +94,9 @@ module.exports = { { "blankLine": "always", "prev": "*", "next": "function" }, { "blankLine": "always", "prev": "*", "next": "class" }, { "blankLine": "always", "prev": ["const", "let", "var"], "next": "*" }, - { "blankLine": "any", "prev": ["const", "let", "var"], "next": ["const", "let", "var"]}, - ] + { "blankLine": "any", "prev": ["const", "let", "var"], "next": ["const", "let", "var"] }, + ], + "no-template-curly-in-string": "error", } }, { @@ -115,6 +126,12 @@ module.exports = { "@typescript-eslint/ban-ts-comment": "off", "@typescript-eslint/no-empty-interface": "off", "@typescript-eslint/no-unused-vars": "off", + "space-before-function-paren": "off", + "@typescript-eslint/space-before-function-paren": ["error", { + "anonymous": "always", + "named": "never", + "asyncArrow": "always", + }], "unused-imports/no-unused-imports-ts": process.env.PROD === "true" ? "error" : "warn", "unused-imports/no-unused-vars-ts": [ "warn", { @@ -130,6 +147,11 @@ module.exports = { "avoidEscape": true, "allowTemplateLiterals": true, }], + "object-curly-spacing": "off", + "@typescript-eslint/object-curly-spacing": ["error", "always", { + "objectsInObjects": false, + "arraysInObjects": true, + }], "react/prop-types": "off", "semi": "off", "@typescript-eslint/semi": ["error"], @@ -138,6 +160,8 @@ module.exports = { "object-shorthand": "error", "prefer-template": "error", "template-curly-spacing": "error", + "no-unused-expressions": "off", + "@typescript-eslint/no-unused-expressions": "error", "padding-line-between-statements": [ "error", { "blankLine": "always", "prev": "*", "next": "return" }, @@ -145,8 +169,9 @@ module.exports = { { "blankLine": "always", "prev": "*", "next": "function" }, { "blankLine": "always", "prev": "*", "next": "class" }, { "blankLine": "always", "prev": ["const", "let", "var"], "next": "*" }, - { "blankLine": "any", "prev": ["const", "let", "var"], "next": ["const", "let", "var"]}, - ] + { "blankLine": "any", "prev": ["const", "let", "var"], "next": ["const", "let", "var"] }, + ], + "no-template-curly-in-string": "error", }, }, { @@ -183,6 +208,12 @@ module.exports = { "@typescript-eslint/no-empty-function": "off", "react/display-name": "off", "@typescript-eslint/no-unused-vars": "off", + "space-before-function-paren": "off", + "@typescript-eslint/space-before-function-paren": ["error", { + "anonymous": "always", + "named": "never", + "asyncArrow": "always", + }], "unused-imports/no-unused-imports-ts": process.env.PROD === "true" ? "error" : "warn", "unused-imports/no-unused-vars-ts": [ "warn", { @@ -198,6 +229,11 @@ module.exports = { "avoidEscape": true, "allowTemplateLiterals": true, }], + "object-curly-spacing": "off", + "@typescript-eslint/object-curly-spacing": ["error", "always", { + "objectsInObjects": false, + "arraysInObjects": true, + }], "react/prop-types": "off", "semi": "off", "@typescript-eslint/semi": ["error"], @@ -206,6 +242,8 @@ module.exports = { "object-shorthand": "error", "prefer-template": "error", "template-curly-spacing": "error", + "no-unused-expressions": "off", + "@typescript-eslint/no-unused-expressions": "error", "padding-line-between-statements": [ "error", { "blankLine": "always", "prev": "*", "next": "return" }, @@ -213,10 +251,11 @@ module.exports = { { "blankLine": "always", "prev": "*", "next": "function" }, { "blankLine": "always", "prev": "*", "next": "class" }, { "blankLine": "always", "prev": ["const", "let", "var"], "next": "*" }, - { "blankLine": "any", "prev": ["const", "let", "var"], "next": ["const", "let", "var"]}, + { "blankLine": "any", "prev": ["const", "let", "var"], "next": ["const", "let", "var"] }, ], "react-hooks/rules-of-hooks": "error", - "react-hooks/exhaustive-deps": "off" + "react-hooks/exhaustive-deps": "off", + "no-template-curly-in-string": "error", }, } ] diff --git a/extensions/metrics-cluster-feature/renderer.tsx b/extensions/metrics-cluster-feature/renderer.tsx index 884f6cd7a2..1d4344e23e 100644 --- a/extensions/metrics-cluster-feature/renderer.tsx +++ b/extensions/metrics-cluster-feature/renderer.tsx @@ -31,7 +31,7 @@ export default class ClusterMetricsFeatureExtension extends Renderer.LensExtensi title: "Lens Metrics", priority: 5, components: { - View: ({ entity = null }: { entity: Common.Catalog.KubernetesCluster}) => { + View: ({ entity = null }: { entity: Common.Catalog.KubernetesCluster }) => { return ( ); diff --git a/extensions/metrics-cluster-feature/src/metrics-feature.ts b/extensions/metrics-cluster-feature/src/metrics-feature.ts index 3401773cdc..7027e4f200 100644 --- a/extensions/metrics-cluster-feature/src/metrics-feature.ts +++ b/extensions/metrics-cluster-feature/src/metrics-feature.ts @@ -92,11 +92,11 @@ export class MetricsFeature { } async getStatus(): Promise { - const status: MetricsStatus = { installed: false, canUpgrade: false}; + const status: MetricsStatus = { installed: false, canUpgrade: false }; try { const namespaceApi = forCluster(this.cluster, Namespace); - const namespace = await namespaceApi.get({name: "lens-metrics"}); + const namespace = await namespaceApi.get({ name: "lens-metrics" }); if (namespace?.kind) { const currentVersion = namespace.metadata.annotations?.extensionVersion || "0.0.0"; diff --git a/extensions/metrics-cluster-feature/src/metrics-settings.tsx b/extensions/metrics-cluster-feature/src/metrics-settings.tsx index f05854b0f2..b0c8bee9b6 100644 --- a/extensions/metrics-cluster-feature/src/metrics-settings.tsx +++ b/extensions/metrics-cluster-feature/src/metrics-settings.tsx @@ -114,7 +114,7 @@ export class MetricsSettings extends React.Component { const statefulSet = forCluster(this.props.cluster, StatefulSet); try { - await statefulSet.get({name: "prometheus", namespace: "lens-metrics"}); + await statefulSet.get({ name: "prometheus", namespace: "lens-metrics" }); this.featureStates.prometheus = true; } catch(e) { if (e?.error?.code === 404) { @@ -127,7 +127,7 @@ export class MetricsSettings extends React.Component { const deployment = forCluster(this.props.cluster, Deployment); try { - await deployment.get({name: "kube-state-metrics", namespace: "lens-metrics"}); + await deployment.get({ name: "kube-state-metrics", namespace: "lens-metrics" }); this.featureStates.kubeStateMetrics = true; } catch(e) { if (e?.error?.code === 404) { @@ -140,7 +140,7 @@ export class MetricsSettings extends React.Component { const daemonSet = forCluster(this.props.cluster, DaemonSet); try { - await daemonSet.get({name: "node-exporter", namespace: "lens-metrics"}); + await daemonSet.get({ name: "node-exporter", namespace: "lens-metrics" }); this.featureStates.nodeExporter = true; } catch(e) { if (e?.error?.code === 404) { @@ -207,14 +207,14 @@ export class MetricsSettings extends React.Component { <> { this.props.cluster.status.phase !== "connected" && (
-

+

Lens Metrics settings requires established connection to the cluster.

)} { !this.isActiveMetricsProvider && (
-

+

Other metrics provider is currently active. See "Metrics" tab for details.

diff --git a/package.json b/package.json index 14c69d9a54..2f046d0bbc 100644 --- a/package.json +++ b/package.json @@ -297,7 +297,7 @@ "@types/request-promise-native": "^1.0.18", "@types/semver": "^7.3.9", "@types/sharp": "^0.29.2", - "@types/spdy": "^3.4.4", + "@types/spdy": "^3.4.5", "@types/tar": "^4.0.5", "@types/tcp-port-used": "^1.0.0", "@types/tempy": "^0.3.0", @@ -378,7 +378,7 @@ "webpack-dev-server": "^3.11.2", "webpack-node-externals": "^1.7.2", "what-input": "^5.2.10", - "xterm": "^4.12.0", + "xterm": "^4.14.1", "xterm-addon-fit": "^0.5.0" } } diff --git a/src/common/__tests__/event-bus.test.ts b/src/common/__tests__/event-bus.test.ts index acc1b70d26..92e4d0628c 100644 --- a/src/common/__tests__/event-bus.test.ts +++ b/src/common/__tests__/event-bus.test.ts @@ -34,7 +34,7 @@ describe("event bus tests", () => { event = data; }); - appEventBus.emit({name: "foo", action: "bar"}); + appEventBus.emit({ name: "foo", action: "bar" }); expect(event.name).toBe("foo"); }); }); diff --git a/src/common/__tests__/kube-helpers.test.ts b/src/common/__tests__/kube-helpers.test.ts index 277398ee02..0bd417b167 100644 --- a/src/common/__tests__/kube-helpers.test.ts +++ b/src/common/__tests__/kube-helpers.test.ts @@ -174,7 +174,7 @@ describe("kube helpers", () => { }); it("multiple context is ok", async () => { - mockKubeConfig.contexts.push({context: {cluster: "cluster-2", user: "cluster-2"}, name: "cluster-2"}); + mockKubeConfig.contexts.push({ context: { cluster: "cluster-2", user: "cluster-2" }, name: "cluster-2" }); const { config } = loadConfigFromString(JSON.stringify(mockKubeConfig)); expect(config.getCurrentContext()).toBe("minikube"); @@ -209,7 +209,7 @@ describe("kube helpers", () => { }); it("empty name in context causes it to be removed", async () => { - mockKubeConfig.contexts.push({context: {cluster: "cluster-2", user: "cluster-2"}, name: ""}); + mockKubeConfig.contexts.push({ context: { cluster: "cluster-2", user: "cluster-2" }, name: "" }); expect(mockKubeConfig.contexts.length).toBe(2); const { config } = loadConfigFromString(JSON.stringify(mockKubeConfig)); @@ -218,7 +218,7 @@ describe("kube helpers", () => { }); it("empty cluster in context causes it to be removed", async () => { - mockKubeConfig.contexts.push({context: {cluster: "", user: "cluster-2"}, name: "cluster-2"}); + mockKubeConfig.contexts.push({ context: { cluster: "", user: "cluster-2" }, name: "cluster-2" }); expect(mockKubeConfig.contexts.length).toBe(2); const { config } = loadConfigFromString(JSON.stringify(mockKubeConfig)); @@ -227,7 +227,7 @@ describe("kube helpers", () => { }); it("empty user in context causes it to be removed", async () => { - mockKubeConfig.contexts.push({context: {cluster: "cluster-2", user: ""}, name: "cluster-2"}); + mockKubeConfig.contexts.push({ context: { cluster: "cluster-2", user: "" }, name: "cluster-2" }); expect(mockKubeConfig.contexts.length).toBe(2); const { config } = loadConfigFromString(JSON.stringify(mockKubeConfig)); @@ -236,8 +236,8 @@ describe("kube helpers", () => { }); it("invalid context in between valid contexts is removed", async () => { - mockKubeConfig.contexts.push({context: {cluster: "cluster-2", user: ""}, name: "cluster-2"}); - mockKubeConfig.contexts.push({context: {cluster: "cluster-3", user: "cluster-3"}, name: "cluster-3"}); + mockKubeConfig.contexts.push({ context: { cluster: "cluster-2", user: "" }, name: "cluster-2" }); + mockKubeConfig.contexts.push({ context: { cluster: "cluster-3", user: "cluster-3" }, name: "cluster-3" }); expect(mockKubeConfig.contexts.length).toBe(3); const { config } = loadConfigFromString(JSON.stringify(mockKubeConfig)); diff --git a/src/common/__tests__/user-store.test.ts b/src/common/__tests__/user-store.test.ts index adfe5ecf4b..2eb0329e72 100644 --- a/src/common/__tests__/user-store.test.ts +++ b/src/common/__tests__/user-store.test.ts @@ -52,7 +52,7 @@ AppPaths.init(); describe("user store tests", () => { describe("for an empty config", () => { beforeEach(() => { - mockFs({ tmp: { "config.json": "{}", "kube_config": "{}" } }); + mockFs({ tmp: { "config.json": "{}", "kube_config": "{}" }}); (UserStore.createInstance() as any).refreshNewContexts = jest.fn(() => Promise.resolve()); }); diff --git a/src/common/getTSLoader.ts b/src/common/getTSLoader.ts index 6c76770d5d..242b134adb 100644 --- a/src/common/getTSLoader.ts +++ b/src/common/getTSLoader.ts @@ -23,20 +23,18 @@ import esbuild from "esbuild"; /** * A function returning webpack ts/tsx loader - * + * * depends on env LENS_DEV_USE_ESBUILD_LOADER to use esbuild-loader (faster) or good-old ts-loader - * - * @param testRegExp - the regex for webpack to conditional find the files + * + * @param testRegExp - the regex for webpack to conditional find the files * @returns ts/tsx webpack loader configuration object */ const getTSLoader = ( testRegExp: RegExp, transpileOnly = true ) => { - const useEsbuildLoader = process.env.LENS_DEV_USE_ESBUILD_LOADER === "true"; + if (process.env.LENS_DEV_USE_ESBUILD_LOADER === "true") { + console.info(`\nšŸš€ using esbuild-loader for ts(x)`); - useEsbuildLoader && console.info(`\nšŸš€ using esbuild-loader for ts(x)`); - - if (useEsbuildLoader) { return { test: testRegExp, loader: "esbuild-loader", diff --git a/src/common/hotbar-store.ts b/src/common/hotbar-store.ts index f7b7de642d..b1a726fac2 100644 --- a/src/common/hotbar-store.ts +++ b/src/common/hotbar-store.ts @@ -73,8 +73,8 @@ export class HotbarStore extends BaseStore { protected fromStore(data: Partial = {}) { if (!data.hotbars || !data.hotbars.length) { const hotbar = getEmptyHotbar("Default"); - const { metadata: { uid, name, source } } = catalogEntity; - const initialItem = { entity: { uid, name, source } }; + const { metadata: { uid, name, source }} = catalogEntity; + const initialItem = { entity: { uid, name, source }}; hotbar.items[0] = initialItem; diff --git a/src/common/k8s-api/__tests__/deployment.api.test.ts b/src/common/k8s-api/__tests__/deployment.api.test.ts index 65d9c93434..a04df9cd85 100644 --- a/src/common/k8s-api/__tests__/deployment.api.test.ts +++ b/src/common/k8s-api/__tests__/deployment.api.test.ts @@ -41,7 +41,7 @@ describe("DeploymentApi", () => { it("requests Kubernetes API with PATCH verb and correct amount of replicas", () => { const patchSpy = jest.spyOn(requestMock, "patch"); - sub.scale({ namespace: "default", name: "deployment-1"}, 5); + sub.scale({ namespace: "default", name: "deployment-1" }, 5); expect(patchSpy).toHaveBeenCalledWith("/apis/apps/v1/namespaces/default/deployments/deployment-1/scale", { data: { diff --git a/src/common/k8s-api/__tests__/kube-object.test.ts b/src/common/k8s-api/__tests__/kube-object.test.ts index 230f5c9d79..cb2a412a5e 100644 --- a/src/common/k8s-api/__tests__/kube-object.test.ts +++ b/src/common/k8s-api/__tests__/kube-object.test.ts @@ -45,12 +45,12 @@ describe("KubeObject", () => { { type TestCase = [string, any]; const tests: TestCase[] = [ - ["kind", { apiVersion: "", metadata: {uid: "", name: "", resourceVersion: "", selfLink: ""} }], - ["apiVersion", { kind: "", metadata: {uid: "", name: "", resourceVersion: "", selfLink: ""} }], + ["kind", { apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "" }}], + ["apiVersion", { kind: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "" }}], ["metadata", { kind: "", apiVersion: "" }], - ["metadata.uid", { kind: "", apiVersion: "", metadata: { name: "", resourceVersion: "", selfLink: ""} }], - ["metadata.name", { kind: "", apiVersion: "", metadata: { uid: "", resourceVersion: "", selfLink: "" } }], - ["metadata.resourceVersion", { kind: "", apiVersion: "", metadata: { uid: "", name: "", selfLink: "" } }], + ["metadata.uid", { kind: "", apiVersion: "", metadata: { name: "", resourceVersion: "", selfLink: "" }}], + ["metadata.name", { kind: "", apiVersion: "", metadata: { uid: "", resourceVersion: "", selfLink: "" }}], + ["metadata.resourceVersion", { kind: "", apiVersion: "", metadata: { uid: "", name: "", selfLink: "" }}], ]; it.each(tests)("should reject with missing: %s", (missingField, input) => { @@ -61,23 +61,23 @@ describe("KubeObject", () => { { type TestCase = [string, any]; const tests: TestCase[] = [ - ["kind", { kind: 1, apiVersion: "", metadata: {} }], - ["apiVersion", { apiVersion: 1, kind: "", metadata: {} }], + ["kind", { kind: 1, apiVersion: "", metadata: {}}], + ["apiVersion", { apiVersion: 1, kind: "", metadata: {}}], ["metadata", { kind: "", apiVersion: "", metadata: "" }], - ["metadata.uid", { kind: "", apiVersion: "", metadata: { uid: 1 } }], - ["metadata.name", { kind: "", apiVersion: "", metadata: { uid: "", name: 1 } }], - ["metadata.resourceVersion", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: 1 } }], - ["metadata.selfLink", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: 1 } }], - ["metadata.namespace", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", namespace: 1 } }], - ["metadata.creationTimestamp", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", creationTimestamp: 1 } }], - ["metadata.continue", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", continue: 1 } }], - ["metadata.finalizers", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", finalizers: 1 } }], - ["metadata.finalizers", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", finalizers: [1] } }], - ["metadata.finalizers", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", finalizers: {} } }], - ["metadata.labels", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", labels: 1 } }], - ["metadata.labels", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", labels: { food: 1 } } }], - ["metadata.annotations", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", annotations: 1 } }], - ["metadata.annotations", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", annotations: { food: 1 } } }], + ["metadata.uid", { kind: "", apiVersion: "", metadata: { uid: 1 }}], + ["metadata.name", { kind: "", apiVersion: "", metadata: { uid: "", name: 1 }}], + ["metadata.resourceVersion", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: 1 }}], + ["metadata.selfLink", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: 1 }}], + ["metadata.namespace", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", namespace: 1 }}], + ["metadata.creationTimestamp", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", creationTimestamp: 1 }}], + ["metadata.continue", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", continue: 1 }}], + ["metadata.finalizers", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", finalizers: 1 }}], + ["metadata.finalizers", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", finalizers: [1] }}], + ["metadata.finalizers", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", finalizers: {}}}], + ["metadata.labels", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", labels: 1 }}], + ["metadata.labels", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", labels: { food: 1 }}}], + ["metadata.annotations", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", annotations: 1 }}], + ["metadata.annotations", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", annotations: { food: 1 }}}], ]; it.each(tests)("should reject with wrong type for field: %s", (missingField, input) => { @@ -86,7 +86,7 @@ describe("KubeObject", () => { } it("should accept valid KubeJsonApiData (ignoring other fields)", () => { - const valid = { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", annotations: { food: "" } } }; + const valid = { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", annotations: { food: "" }}}; expect(KubeObject.isJsonApiData(valid)).toBe(true); }); @@ -118,8 +118,8 @@ describe("KubeObject", () => { { type TestCase = [string, any]; const tests: TestCase[] = [ - ["kind", { apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "" } }], - ["apiVersion", { kind: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "" } }], + ["kind", { apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "" }}], + ["apiVersion", { kind: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "" }}], ["metadata", { kind: "", apiVersion: "" }], ]; @@ -131,23 +131,23 @@ describe("KubeObject", () => { { type TestCase = [string, any]; const tests: TestCase[] = [ - ["kind", { kind: 1, apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "" } }], - ["apiVersion", { apiVersion: 1, kind: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "" } }], + ["kind", { kind: 1, apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "" }}], + ["apiVersion", { apiVersion: 1, kind: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "" }}], ["metadata", { kind: "", apiVersion: "", metadata: "" }], - ["metadata.uid", { kind: "", apiVersion: "", metadata: { uid: 1, name: "", resourceVersion: "", selfLink: "" } }], - ["metadata.name", { kind: "", apiVersion: "", metadata: { uid: "", name: 1, resourceVersion: "", selfLink: "" } }], - ["metadata.resourceVersion", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: 1, selfLink: "" } }], - ["metadata.selfLink", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: 1 } }], - ["metadata.namespace", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", namespace: 1 } }], - ["metadata.creationTimestamp", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", creationTimestamp: 1 } }], - ["metadata.continue", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", continue: 1 } }], - ["metadata.finalizers", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", finalizers: 1 } }], - ["metadata.finalizers", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", finalizers: [1] } }], - ["metadata.finalizers", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", finalizers: {} } }], - ["metadata.labels", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", labels: 1 } }], - ["metadata.labels", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", labels: { food: 1 } } }], - ["metadata.annotations", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", annotations: 1 } }], - ["metadata.annotations", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", annotations: { food: 1 } } }], + ["metadata.uid", { kind: "", apiVersion: "", metadata: { uid: 1, name: "", resourceVersion: "", selfLink: "" }}], + ["metadata.name", { kind: "", apiVersion: "", metadata: { uid: "", name: 1, resourceVersion: "", selfLink: "" }}], + ["metadata.resourceVersion", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: 1, selfLink: "" }}], + ["metadata.selfLink", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: 1 }}], + ["metadata.namespace", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", namespace: 1 }}], + ["metadata.creationTimestamp", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", creationTimestamp: 1 }}], + ["metadata.continue", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", continue: 1 }}], + ["metadata.finalizers", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", finalizers: 1 }}], + ["metadata.finalizers", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", finalizers: [1] }}], + ["metadata.finalizers", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", finalizers: {}}}], + ["metadata.labels", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", labels: 1 }}], + ["metadata.labels", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", labels: { food: 1 }}}], + ["metadata.annotations", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", annotations: 1 }}], + ["metadata.annotations", { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", annotations: { food: 1 }}}], ]; it.each(tests)("should reject with wrong type for field: %s", (missingField, input) => { @@ -156,7 +156,7 @@ describe("KubeObject", () => { } it("should accept valid Partial (ignoring other fields)", () => { - const valid = { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", annotations: { food: "" } } }; + const valid = { kind: "", apiVersion: "", metadata: { uid: "", name: "", resourceVersion: "", selfLink: "", annotations: { food: "" }}}; expect(KubeObject.isPartialJsonApiData(valid)).toBe(true); }); @@ -197,8 +197,8 @@ describe("KubeObject", () => { { type TestCase = [string, any]; const tests: TestCase[] = [ - ["kind", { apiVersion: "", items: [], metadata: { resourceVersion: "", selfLink: "" } }], - ["apiVersion", { kind: "", items: [], metadata: { resourceVersion: "", selfLink: "" } }], + ["kind", { apiVersion: "", items: [], metadata: { resourceVersion: "", selfLink: "" }}], + ["apiVersion", { kind: "", items: [], metadata: { resourceVersion: "", selfLink: "" }}], ["metadata", { kind: "", items: [], apiVersion: "" }], ]; @@ -210,15 +210,15 @@ describe("KubeObject", () => { { type TestCase = [string, any]; const tests: TestCase[] = [ - ["kind", { kind: 1, items: [], apiVersion: "", metadata: { resourceVersion: "", selfLink: "" } }], - ["apiVersion", { kind: "", items: [], apiVersion: 1, metadata: { resourceVersion: "", selfLink: "" } }], + ["kind", { kind: 1, items: [], apiVersion: "", metadata: { resourceVersion: "", selfLink: "" }}], + ["apiVersion", { kind: "", items: [], apiVersion: 1, metadata: { resourceVersion: "", selfLink: "" }}], ["metadata", { kind: "", items: [], apiVersion: "", metadata: 1 }], - ["metadata.resourceVersion", { kind: "", items: [], apiVersion: "", metadata: { resourceVersion: 1, selfLink: "" } }], - ["metadata.selfLink", { kind: "", items: [], apiVersion: "", metadata: { resourceVersion: "", selfLink: 1 } }], - ["items", { kind: "", items: 1, apiVersion: "", metadata: { resourceVersion: "", selfLink: "" } }], - ["items", { kind: "", items: "", apiVersion: "", metadata: { resourceVersion: "", selfLink: "" } }], - ["items", { kind: "", items: {}, apiVersion: "", metadata: { resourceVersion: "", selfLink: "" } }], - ["items[0]", { kind: "", items: [""], apiVersion: "", metadata: { resourceVersion: "", selfLink: "" } }], + ["metadata.resourceVersion", { kind: "", items: [], apiVersion: "", metadata: { resourceVersion: 1, selfLink: "" }}], + ["metadata.selfLink", { kind: "", items: [], apiVersion: "", metadata: { resourceVersion: "", selfLink: 1 }}], + ["items", { kind: "", items: 1, apiVersion: "", metadata: { resourceVersion: "", selfLink: "" }}], + ["items", { kind: "", items: "", apiVersion: "", metadata: { resourceVersion: "", selfLink: "" }}], + ["items", { kind: "", items: {}, apiVersion: "", metadata: { resourceVersion: "", selfLink: "" }}], + ["items[0]", { kind: "", items: [""], apiVersion: "", metadata: { resourceVersion: "", selfLink: "" }}], ]; it.each(tests)("should reject with wrong type for field: %s", (missingField, input) => { @@ -227,7 +227,7 @@ describe("KubeObject", () => { } it("should accept valid KubeJsonApiDataList (ignoring other fields)", () => { - const valid = { kind: "", items: [false], apiVersion: "", metadata: { resourceVersion: "", selfLink: "" } }; + const valid = { kind: "", items: [false], apiVersion: "", metadata: { resourceVersion: "", selfLink: "" }}; expect(KubeObject.isJsonApiDataList(valid, isBoolean)).toBe(true); }); diff --git a/src/common/k8s-api/__tests__/stateful-set.api.test.ts b/src/common/k8s-api/__tests__/stateful-set.api.test.ts index d1b90be181..1c926a7a19 100644 --- a/src/common/k8s-api/__tests__/stateful-set.api.test.ts +++ b/src/common/k8s-api/__tests__/stateful-set.api.test.ts @@ -41,7 +41,7 @@ describe("StatefulSetApi", () => { it("requests Kubernetes API with PATCH verb and correct amount of replicas", () => { const patchSpy = jest.spyOn(requestMock, "patch"); - sub.scale({ namespace: "default", name: "statefulset-1"}, 5); + sub.scale({ namespace: "default", name: "statefulset-1" }, 5); expect(patchSpy).toHaveBeenCalledWith("/apis/apps/v1/namespaces/default/statefulsets/statefulset-1/scale", { data: { diff --git a/src/common/k8s-api/endpoints/crd.api.ts b/src/common/k8s-api/endpoints/crd.api.ts index 98c8d38df0..e12d7069ed 100644 --- a/src/common/k8s-api/endpoints/crd.api.ts +++ b/src/common/k8s-api/endpoints/crd.api.ts @@ -163,7 +163,7 @@ export class CustomResourceDefinition extends KubeObject { } } else if (this.spec.version) { const { additionalPrinterColumns: apc } = this.spec; - const additionalPrinterColumns = apc?.map(({ JSONPath, ...apc}) => ({ ...apc, jsonPath: JSONPath })); + const additionalPrinterColumns = apc?.map(({ JSONPath, ...apc }) => ({ ...apc, jsonPath: JSONPath })); return { name: this.spec.version, diff --git a/src/common/k8s-api/endpoints/deployment.api.ts b/src/common/k8s-api/endpoints/deployment.api.ts index 721db669b7..17a5456c2d 100644 --- a/src/common/k8s-api/endpoints/deployment.api.ts +++ b/src/common/k8s-api/endpoints/deployment.api.ts @@ -61,7 +61,7 @@ export class DeploymentApi extends KubeApi { spec: { template: { metadata: { - annotations: {"kubectl.kubernetes.io/restartedAt" : moment.utc().format()} + annotations: { "kubectl.kubernetes.io/restartedAt" : moment.utc().format() } } } } @@ -122,7 +122,7 @@ export class Deployment extends WorkloadKubeObject { declare spec: { replicas: number; - selector: { matchLabels: { [app: string]: string } }; + selector: { matchLabels: { [app: string]: string }}; template: { metadata: { creationTimestamp?: string; diff --git a/src/common/k8s-api/endpoints/endpoint.api.ts b/src/common/k8s-api/endpoints/endpoint.api.ts index e6dceb2b8f..ce3bf1ceff 100644 --- a/src/common/k8s-api/endpoints/endpoint.api.ts +++ b/src/common/k8s-api/endpoints/endpoint.api.ts @@ -83,7 +83,7 @@ export class EndpointAddress implements IEndpointAddress { getTargetRef(): ITargetRef { if (this.targetRef) { - return Object.assign(this.targetRef, {apiVersion: "v1"}); + return Object.assign(this.targetRef, { apiVersion: "v1" }); } else { return null; } diff --git a/src/common/k8s-api/endpoints/ingress.api.ts b/src/common/k8s-api/endpoints/ingress.api.ts index cf607fa144..2644fecf57 100644 --- a/src/common/k8s-api/endpoints/ingress.api.ts +++ b/src/common/k8s-api/endpoints/ingress.api.ts @@ -128,7 +128,7 @@ export class Ingress extends KubeObject { } getRoutes() { - const { spec: { tls, rules } } = this; + const { spec: { tls, rules }} = this; if (!rules) return []; @@ -165,7 +165,7 @@ export class Ingress extends KubeObject { } getHosts() { - const { spec: { rules } } = this; + const { spec: { rules }} = this; if (!rules) return []; @@ -174,7 +174,7 @@ export class Ingress extends KubeObject { getPorts() { const ports: number[] = []; - const { spec: { tls, rules, backend, defaultBackend } } = this; + const { spec: { tls, rules, backend, defaultBackend }} = this; const httpPort = 80; const tlsPort = 443; // Note: not using the port name (string) @@ -196,7 +196,7 @@ export class Ingress extends KubeObject { } getLoadBalancers() { - const { status: { loadBalancer = { ingress: [] } } } = this; + const { status: { loadBalancer = { ingress: [] }}} = this; return (loadBalancer.ingress ?? []).map(address => ( address.hostname || address.ip diff --git a/src/common/k8s-api/endpoints/nodes.api.ts b/src/common/k8s-api/endpoints/nodes.api.ts index bd09044776..094fa23784 100644 --- a/src/common/k8s-api/endpoints/nodes.api.ts +++ b/src/common/k8s-api/endpoints/nodes.api.ts @@ -30,7 +30,7 @@ export class NodesApi extends KubeApi { } export function getMetricsForAllNodes(): Promise { - const opts = { category: "nodes"}; + const opts = { category: "nodes" }; return metricsApi.getMetrics({ memoryUsage: opts, diff --git a/src/common/k8s-api/endpoints/poddisruptionbudget.api.ts b/src/common/k8s-api/endpoints/poddisruptionbudget.api.ts index 1e57c1a3ec..0199aff815 100644 --- a/src/common/k8s-api/endpoints/poddisruptionbudget.api.ts +++ b/src/common/k8s-api/endpoints/poddisruptionbudget.api.ts @@ -29,7 +29,7 @@ export interface PodDisruptionBudget { spec: { minAvailable: string; maxUnavailable: string; - selector: { matchLabels: { [app: string]: string } }; + selector: { matchLabels: { [app: string]: string }}; }; status: { currentHealthy: number diff --git a/src/common/k8s-api/endpoints/pods.api.ts b/src/common/k8s-api/endpoints/pods.api.ts index 70fad21b4b..cdff83b271 100644 --- a/src/common/k8s-api/endpoints/pods.api.ts +++ b/src/common/k8s-api/endpoints/pods.api.ts @@ -411,7 +411,7 @@ export class Pod extends WorkloadKubeObject { } getNodeSelectors(): string[] { - const { nodeSelector = {} } = this.spec; + const { nodeSelector = {}} = this.spec; return Object.entries(nodeSelector).map(values => values.join(": ")); } diff --git a/src/common/k8s-api/endpoints/replica-set.api.ts b/src/common/k8s-api/endpoints/replica-set.api.ts index eeaf361557..90fedc5136 100644 --- a/src/common/k8s-api/endpoints/replica-set.api.ts +++ b/src/common/k8s-api/endpoints/replica-set.api.ts @@ -78,7 +78,7 @@ export class ReplicaSet extends WorkloadKubeObject { declare spec: { replicas?: number; - selector: { matchLabels: { [app: string]: string } }; + selector: { matchLabels: { [app: string]: string }}; template?: { metadata: { labels: { diff --git a/src/common/k8s-api/endpoints/service.api.ts b/src/common/k8s-api/endpoints/service.api.ts index e5af9de828..f78d8e6be8 100644 --- a/src/common/k8s-api/endpoints/service.api.ts +++ b/src/common/k8s-api/endpoints/service.api.ts @@ -53,7 +53,7 @@ export interface Service { clusterIP: string; clusterIPs?: string[]; externalTrafficPolicy?: string; - externalName: string; + externalName?: string; loadBalancerIP?: string; loadBalancerSourceRanges?: string[]; sessionAffinity: string; @@ -100,11 +100,15 @@ export class Service extends KubeObject { getExternalIps() { const lb = this.getLoadBalancer(); - if (lb && lb.ingress) { + if (lb?.ingress) { return lb.ingress.map(val => val.ip || val.hostname); } - return this.spec.externalIPs || []; + if (Array.isArray(this.spec?.externalIPs)) { + return this.spec.externalIPs; + } + + return []; } getType() { diff --git a/src/common/k8s-api/kube-object.store.ts b/src/common/k8s-api/kube-object.store.ts index e8b13d8cd7..9dc93f2b5f 100644 --- a/src/common/k8s-api/kube-object.store.ts +++ b/src/common/k8s-api/kube-object.store.ts @@ -376,8 +376,8 @@ export abstract class KubeObjectStore extends ItemStore timedRetry = setTimeout(() => { ( namespace - ? this.loadAll({ namespaces: [namespace], reqInit: { signal } }) - : this.loadAll({ merge: false, reqInit: { signal } }) + ? this.loadAll({ namespaces: [namespace], reqInit: { signal }}) + : this.loadAll({ merge: false, reqInit: { signal }}) ).then(watch); }, 1000); } else if (error) { // not sure what to do, best to retry diff --git a/src/common/k8s-api/kube-watch-api.ts b/src/common/k8s-api/kube-watch-api.ts index 5ce16dcfbd..bcb7c48de2 100644 --- a/src/common/k8s-api/kube-watch-api.ts +++ b/src/common/k8s-api/kube-watch-api.ts @@ -134,7 +134,7 @@ export class KubeWatchApi { }; } - protected log({ message, cssStyle = "", meta = {} }: IKubeWatchLog) { + protected log({ message, cssStyle = "", meta = {}}: IKubeWatchLog) { if (isProduction && !isDebugging) { return; } diff --git a/src/common/utils/autobind.ts b/src/common/utils/autobind.ts index cdb6903259..583d4c4bc5 100644 --- a/src/common/utils/autobind.ts +++ b/src/common/utils/autobind.ts @@ -19,7 +19,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import {boundMethod, boundClass} from "autobind-decorator"; +import { boundMethod, boundClass } from "autobind-decorator"; import autoBindClass, { Options } from "auto-bind"; import autoBindReactClass from "auto-bind/react"; diff --git a/src/common/utils/buildUrl.ts b/src/common/utils/buildUrl.ts index 20e6e7e861..03909917eb 100644 --- a/src/common/utils/buildUrl.ts +++ b/src/common/utils/buildUrl.ts @@ -45,7 +45,7 @@ export function buildURL

(path: str export function buildURLPositional

(path: string | any) { const builder = buildURL(path); - return function(params?: P, query?: Q, fragment?: string): string { + return function (params?: P, query?: Q, fragment?: string): string { return builder({ params, query, fragment }); }; } diff --git a/src/extensions/__tests__/extension-compatibility.test.ts b/src/extensions/__tests__/extension-compatibility.test.ts index d8e789a9d9..d03fcbe712 100644 --- a/src/extensions/__tests__/extension-compatibility.test.ts +++ b/src/extensions/__tests__/extension-compatibility.test.ts @@ -37,7 +37,7 @@ describe("extension compatibility", () => { }); it("has no extension comparator", () => { - const manifest = { name: "extensionName", version: "0.0.1"}; + const manifest = { name: "extensionName", version: "0.0.1" }; expect(isCompatibleExtension(manifest,)).toBe(false); }); @@ -76,7 +76,7 @@ describe("extension compatibility", () => { expected: false, }, ])("extension comparator test: %p", ({ comparator, expected }) => { - const manifest: LensExtensionManifest = { name: "extensionName", version: "0.0.1", engines: { lens: comparator}}; + const manifest: LensExtensionManifest = { name: "extensionName", version: "0.0.1", engines: { lens: comparator }}; expect(isCompatibleExtension(manifest,)).toBe(expected); }); @@ -91,7 +91,7 @@ describe("extension compatibility", () => { }); it("has no extension comparator", () => { - const manifest = { name: "extensionName", version: "0.0.1"}; + const manifest = { name: "extensionName", version: "0.0.1" }; expect(isCompatibleExtension(manifest,)).toBe(false); }); @@ -130,7 +130,7 @@ describe("extension compatibility", () => { expected: false, }, ])("extension comparator test: %p", ({ comparator, expected }) => { - const manifest: LensExtensionManifest = { name: "extensionName", version: "0.0.1", engines: { lens: comparator}}; + const manifest: LensExtensionManifest = { name: "extensionName", version: "0.0.1", engines: { lens: comparator }}; expect(isCompatibleExtension(manifest,)).toBe(expected); }); diff --git a/src/extensions/extensions-store.ts b/src/extensions/extensions-store.ts index be40181242..681735bfbb 100644 --- a/src/extensions/extensions-store.ts +++ b/src/extensions/extensions-store.ts @@ -45,8 +45,8 @@ export class ExtensionsStore extends BaseStore { @computed get enabledExtensions() { return Array.from(this.state.values()) - .filter(({enabled}) => enabled) - .map(({name}) => name); + .filter(({ enabled }) => enabled) + .map(({ name }) => name); } protected state = observable.map(); diff --git a/src/extensions/ipc/ipc-main.ts b/src/extensions/ipc/ipc-main.ts index 09d26b00fb..05d225cb7c 100644 --- a/src/extensions/ipc/ipc-main.ts +++ b/src/extensions/ipc/ipc-main.ts @@ -44,12 +44,12 @@ export abstract class IpcMain extends IpcRegistrar { listen(channel: string, listener: (event: Electron.IpcRendererEvent, ...args: any[]) => any): Disposer { const prefixedChannel = `extensions@${this[IpcPrefix]}:${channel}`; const cleanup = once(() => { - logger.info(`[IPC-RENDERER]: removing extension listener`, { channel, extension: { name: this.extension.name, version: this.extension.version } }); + logger.info(`[IPC-RENDERER]: removing extension listener`, { channel, extension: { name: this.extension.name, version: this.extension.version }}); return ipcMain.removeListener(prefixedChannel, listener); }); - logger.info(`[IPC-RENDERER]: adding extension listener`, { channel, extension: { name: this.extension.name, version: this.extension.version } }); + logger.info(`[IPC-RENDERER]: adding extension listener`, { channel, extension: { name: this.extension.name, version: this.extension.version }}); ipcMain.addListener(prefixedChannel, listener); this.extension[Disposers].push(cleanup); @@ -64,10 +64,10 @@ export abstract class IpcMain extends IpcRegistrar { handle(channel: string, handler: (event: Electron.IpcMainInvokeEvent, ...args: any[]) => any): void { const prefixedChannel = `extensions@${this[IpcPrefix]}:${channel}`; - logger.info(`[IPC-RENDERER]: adding extension handler`, { channel, extension: { name: this.extension.name, version: this.extension.version } }); + logger.info(`[IPC-RENDERER]: adding extension handler`, { channel, extension: { name: this.extension.name, version: this.extension.version }}); ipcMainHandle(prefixedChannel, handler); this.extension[Disposers].push(() => { - logger.info(`[IPC-RENDERER]: removing extension handler`, { channel, extension: { name: this.extension.name, version: this.extension.version } }); + logger.info(`[IPC-RENDERER]: removing extension handler`, { channel, extension: { name: this.extension.name, version: this.extension.version }}); return ipcMain.removeHandler(prefixedChannel); }); diff --git a/src/extensions/ipc/ipc-renderer.ts b/src/extensions/ipc/ipc-renderer.ts index 364ebc5d73..6ec4b870b7 100644 --- a/src/extensions/ipc/ipc-renderer.ts +++ b/src/extensions/ipc/ipc-renderer.ts @@ -44,12 +44,12 @@ export abstract class IpcRenderer extends IpcRegistrar { listen(channel: string, listener: (event: Electron.IpcRendererEvent, ...args: any[]) => any): Disposer { const prefixedChannel = `extensions@${this[IpcPrefix]}:${channel}`; const cleanup = once(() => { - console.info(`[IPC-RENDERER]: removing extension listener`, { channel, extension: { name: this.extension.name, version: this.extension.version } }); + console.info(`[IPC-RENDERER]: removing extension listener`, { channel, extension: { name: this.extension.name, version: this.extension.version }}); return ipcRenderer.removeListener(prefixedChannel, listener); }); - console.info(`[IPC-RENDERER]: adding extension listener`, { channel, extension: { name: this.extension.name, version: this.extension.version } }); + console.info(`[IPC-RENDERER]: adding extension listener`, { channel, extension: { name: this.extension.name, version: this.extension.version }}); ipcRenderer.addListener(prefixedChannel, listener); this.extension[Disposers].push(cleanup); diff --git a/src/extensions/registries/page-registry.ts b/src/extensions/registries/page-registry.ts index 3e97d15c3f..006e5b8e38 100644 --- a/src/extensions/registries/page-registry.ts +++ b/src/extensions/registries/page-registry.ts @@ -66,7 +66,7 @@ export interface RegisteredPage { } export function getExtensionPageUrl(target: PageTarget): string { - const { extensionId, pageId = "", params: targetParams = {} } = target; + const { extensionId, pageId = "", params: targetParams = {}} = target; const pagePath = ["/extension", sanitizeExtensionName(extensionId), pageId] .filter(Boolean) diff --git a/src/main/catalog-sources/kubeconfig-sync.ts b/src/main/catalog-sources/kubeconfig-sync.ts index 14d7bef128..6fe7131f99 100644 --- a/src/main/catalog-sources/kubeconfig-sync.ts +++ b/src/main/catalog-sources/kubeconfig-sync.ts @@ -212,7 +212,7 @@ export function computeDiff(contents: string, source: RootSource, filePath: stri // add new clusters to the source try { const clusterId = createHash("md5").update(`${filePath}:${contextName}`).digest("hex"); - const cluster = ClusterStore.getInstance().getById(clusterId) || new Cluster({ ...model, id: clusterId}); + const cluster = ClusterStore.getInstance().getById(clusterId) || new Cluster({ ...model, id: clusterId }); if (!cluster.apiUrl) { throw new Error("Cluster constructor failed, see above error"); diff --git a/src/main/catalog-sources/weblinks.ts b/src/main/catalog-sources/weblinks.ts index c8e983f3be..a740a1e560 100644 --- a/src/main/catalog-sources/weblinks.ts +++ b/src/main/catalog-sources/weblinks.ts @@ -100,7 +100,7 @@ export function syncWeblinks() { webLinkEntities.delete(weblinkId); } } - }, {fireImmediately: true}); + }, { fireImmediately: true }); catalogEntityRegistry.addComputedSource("weblinks", computed(() => Array.from(webLinkEntities.values(), ([link]) => link))); } diff --git a/src/main/cluster-detectors/detector-registry.ts b/src/main/cluster-detectors/detector-registry.ts index 5d3461b0bb..5f4f12175e 100644 --- a/src/main/cluster-detectors/detector-registry.ts +++ b/src/main/cluster-detectors/detector-registry.ts @@ -35,7 +35,7 @@ export class DetectorRegistry extends Singleton { } async detectForCluster(cluster: Cluster): Promise { - const results: {[key: string]: ClusterDetectionResult } = {}; + const results: { [key: string]: ClusterDetectionResult } = {}; for (const detectorClass of this.registry) { const detector = new detectorClass(cluster); diff --git a/src/main/cluster-detectors/distribution-detector.ts b/src/main/cluster-detectors/distribution-detector.ts index 98173ef81c..6ad2df8815 100644 --- a/src/main/cluster-detectors/distribution-detector.ts +++ b/src/main/cluster-detectors/distribution-detector.ts @@ -30,86 +30,86 @@ export class DistributionDetector extends BaseClusterDetector { this.version = await this.getKubernetesVersion(); if (this.isRke()) { - return { value: "rke", accuracy: 80}; + return { value: "rke", accuracy: 80 }; } if (this.isRancherDesktop()) { - return { value: "rancher-desktop", accuracy: 80}; + return { value: "rancher-desktop", accuracy: 80 }; } if (this.isK3s()) { - return { value: "k3s", accuracy: 80}; + return { value: "k3s", accuracy: 80 }; } if (this.isGKE()) { - return { value: "gke", accuracy: 80}; + return { value: "gke", accuracy: 80 }; } if (this.isEKS()) { - return { value: "eks", accuracy: 80}; + return { value: "eks", accuracy: 80 }; } if (this.isIKS()) { - return { value: "iks", accuracy: 80}; + return { value: "iks", accuracy: 80 }; } if (this.isAKS()) { - return { value: "aks", accuracy: 80}; + return { value: "aks", accuracy: 80 }; } if (this.isDigitalOcean()) { - return { value: "digitalocean", accuracy: 90}; + return { value: "digitalocean", accuracy: 90 }; } if (this.isK0s()) { - return { value: "k0s", accuracy: 80}; + return { value: "k0s", accuracy: 80 }; } if (this.isVMWare()) { - return { value: "vmware", accuracy: 90}; + return { value: "vmware", accuracy: 90 }; } if (this.isMirantis()) { - return { value: "mirantis", accuracy: 90}; + return { value: "mirantis", accuracy: 90 }; } if (this.isAlibaba()) { - return { value: "alibaba", accuracy: 90}; + return { value: "alibaba", accuracy: 90 }; } if (this.isHuawei()) { - return { value: "huawei", accuracy: 90}; + return { value: "huawei", accuracy: 90 }; } if (this.isTke()) { - return { value: "tencent", accuracy: 90}; + return { value: "tencent", accuracy: 90 }; } if (this.isMinikube()) { - return { value: "minikube", accuracy: 80}; + return { value: "minikube", accuracy: 80 }; } if (this.isMicrok8s()) { - return { value: "microk8s", accuracy: 80}; + return { value: "microk8s", accuracy: 80 }; } if (this.isKind()) { - return { value: "kind", accuracy: 70}; + return { value: "kind", accuracy: 70 }; } if (this.isDockerDesktop()) { - return { value: "docker-desktop", accuracy: 80}; + return { value: "docker-desktop", accuracy: 80 }; } if (this.isCustom() && await this.isOpenshift()) { - return { value: "openshift", accuracy: 90}; + return { value: "openshift", accuracy: 90 }; } if (this.isCustom()) { - return { value: "custom", accuracy: 10}; + return { value: "custom", accuracy: 10 }; } - return { value: "unknown", accuracy: 10}; + return { value: "unknown", accuracy: 10 }; } public async getKubernetesVersion() { diff --git a/src/main/cluster-detectors/nodes-count-detector.ts b/src/main/cluster-detectors/nodes-count-detector.ts index 2cb224b46a..75f478549b 100644 --- a/src/main/cluster-detectors/nodes-count-detector.ts +++ b/src/main/cluster-detectors/nodes-count-detector.ts @@ -29,7 +29,7 @@ export class NodesCountDetector extends BaseClusterDetector { if (!this.cluster.accessible) return null; const nodeCount = await this.getNodeCount(); - return { value: nodeCount, accuracy: 100}; + return { value: nodeCount, accuracy: 100 }; } protected async getNodeCount(): Promise { diff --git a/src/main/cluster-detectors/version-detector.ts b/src/main/cluster-detectors/version-detector.ts index 36d7e06dd1..ecabb1ec49 100644 --- a/src/main/cluster-detectors/version-detector.ts +++ b/src/main/cluster-detectors/version-detector.ts @@ -29,7 +29,7 @@ export class VersionDetector extends BaseClusterDetector { public async detect() { const version = await this.getKubernetesVersion(); - return { value: version, accuracy: 100}; + return { value: version, accuracy: 100 }; } public async getKubernetesVersion() { diff --git a/src/main/cluster.ts b/src/main/cluster.ts index 4ac4074ca5..76197ade77 100644 --- a/src/main/cluster.ts +++ b/src/main/cluster.ts @@ -651,7 +651,7 @@ export class Cluster implements ClusterModel, ClusterState { const api = (await this.getProxyKubeconfig()).makeApiClient(CoreV1Api); try { - const { body: { items } } = await api.listNamespace(); + const { body: { items }} = await api.listNamespace(); const namespaces = items.map(ns => ns.metadata.name); return namespaces; diff --git a/src/main/extension-filesystem.ts b/src/main/extension-filesystem.ts index 849165afa4..97c8bf06a3 100644 --- a/src/main/extension-filesystem.ts +++ b/src/main/extension-filesystem.ts @@ -68,7 +68,7 @@ export class FilesystemProvisionerStore extends BaseStore { } @action - protected fromStore({ extensions }: FSProvisionModel = { extensions: {} }): void { + protected fromStore({ extensions }: FSProvisionModel = { extensions: {}}): void { this.registeredExtensions.merge(extensions); } diff --git a/src/main/kubectl.ts b/src/main/kubectl.ts index c68e00b2dd..9454ec33fd 100644 --- a/src/main/kubectl.ts +++ b/src/main/kubectl.ts @@ -346,10 +346,10 @@ export class Kubectl { bashScript += `export PATH="${helmPath}:${kubectlPath}:$PATH"\n`; bashScript += "export KUBECONFIG=\"$tempkubeconfig\"\n"; - bashScript += "NO_PROXY=\",${NO_PROXY:-localhost},\"\n"; - bashScript += "NO_PROXY=\"${NO_PROXY//,localhost,/,}\"\n"; - bashScript += "NO_PROXY=\"${NO_PROXY//,127.0.0.1,/,}\"\n"; - bashScript += "NO_PROXY=\"localhost,127.0.0.1${NO_PROXY%,}\"\n"; + bashScript += `NO_PROXY=\",\${NO_PROXY:-localhost},\"\n`; + bashScript += `NO_PROXY=\"\${NO_PROXY//,localhost,/,}\"\n`; + bashScript += `NO_PROXY=\"\${NO_PROXY//,127.0.0.1,/,}\"\n`; + bashScript += `NO_PROXY=\"localhost,127.0.0.1\${NO_PROXY%,}\"\n`; bashScript += "export NO_PROXY\n"; bashScript += "unset tempkubeconfig\n"; await fsPromises.writeFile(bashScriptPath, bashScript.toString(), { mode: 0o644 }); @@ -371,14 +371,14 @@ export class Kubectl { zshScript += `helmpath=\"${helmPath}"\n`; zshScript += "p=\":$kubectlpath:\"\n"; zshScript += "d=\":$PATH:\"\n"; - zshScript += "d=${d//$p/:}\n"; - zshScript += "d=${d/#:/}\n"; - zshScript += "export PATH=\"$helmpath:$kubectlpath:${d/%:/}\"\n"; + zshScript += `d=\${d//$p/:}\n`; + zshScript += `d=\${d/#:/}\n`; + zshScript += `export PATH=\"$helmpath:$kubectlpath:\${d/%:/}\"\n`; zshScript += "export KUBECONFIG=\"$tempkubeconfig\"\n"; - zshScript += "NO_PROXY=\",${NO_PROXY:-localhost},\"\n"; - zshScript += "NO_PROXY=\"${NO_PROXY//,localhost,/,}\"\n"; - zshScript += "NO_PROXY=\"${NO_PROXY//,127.0.0.1,/,}\"\n"; - zshScript += "NO_PROXY=\"localhost,127.0.0.1${NO_PROXY%,}\"\n"; + zshScript += `NO_PROXY=\",\${NO_PROXY:-localhost},\"\n`; + zshScript += `NO_PROXY=\"\${NO_PROXY//,localhost,/,}\"\n`; + zshScript += `NO_PROXY=\"\${NO_PROXY//,127.0.0.1,/,}\"\n`; + zshScript += `NO_PROXY=\"localhost,127.0.0.1\${NO_PROXY%,}\"\n`; zshScript += "export NO_PROXY\n"; zshScript += "unset tempkubeconfig\n"; zshScript += "unset OLD_ZDOTDIR\n"; diff --git a/src/main/prometheus/provider-registry.ts b/src/main/prometheus/provider-registry.ts index be4dcef737..c63fa0cc39 100644 --- a/src/main/prometheus/provider-registry.ts +++ b/src/main/prometheus/provider-registry.ts @@ -46,7 +46,7 @@ export abstract class PrometheusProvider { protected async getFirstNamespacedServer(client: CoreV1Api, ...selectors: string[]): Promise { try { for (const selector of selectors) { - const { body: { items: [service] } } = await client.listServiceForAllNamespaces(null, null, null, selector); + const { body: { items: [service] }} = await client.listServiceForAllNamespaces(null, null, null, selector); if (service) { return { diff --git a/src/main/router.ts b/src/main/router.ts index 9a7ded8a37..bab5647506 100644 --- a/src/main/router.ts +++ b/src/main/router.ts @@ -122,7 +122,7 @@ export class Router { }; } - protected static async handleStaticFile({ params, response, raw: { req } }: LensApiRequest): Promise { + protected static async handleStaticFile({ params, response, raw: { req }}: LensApiRequest): Promise { let filePath = params.path; for (let retryCount = 0; retryCount < 5; retryCount += 1) { diff --git a/src/main/routes/kubeconfig-route.ts b/src/main/routes/kubeconfig-route.ts index f4bd7f038e..91f9eea00b 100644 --- a/src/main/routes/kubeconfig-route.ts +++ b/src/main/routes/kubeconfig-route.ts @@ -63,7 +63,7 @@ function generateKubeConfig(username: string, secret: V1Secret, cluster: Cluster export class KubeconfigRoute { static async routeServiceAccountRoute(request: LensApiRequest) { - const { params, response, cluster} = request; + const { params, response, cluster } = request; const client = (await cluster.getProxyKubeconfig()).makeApiClient(CoreV1Api); const secretList = await client.listNamespacedSecret(params.namespace); const secret = secretList.body.items.find(secret => { diff --git a/src/main/routes/version-route.ts b/src/main/routes/version-route.ts index 14a1624489..fa92509d0e 100644 --- a/src/main/routes/version-route.ts +++ b/src/main/routes/version-route.ts @@ -27,6 +27,6 @@ export class VersionRoute { static async getVersion(request: LensApiRequest) { const { response } = request; - respondJson(response, { version: getAppVersion()}, 200); + respondJson(response, { version: getAppVersion() }, 200); } } diff --git a/src/migrations/cluster-store/2.4.1.ts b/src/migrations/cluster-store/2.4.1.ts index 192f7f3dc8..71ac22551f 100644 --- a/src/migrations/cluster-store/2.4.1.ts +++ b/src/migrations/cluster-store/2.4.1.ts @@ -32,7 +32,7 @@ export default { if (contextName === "__internal__") continue; const cluster = value[1]; - store.set(contextName, { kubeConfig: cluster.kubeConfig, icon: cluster.icon || null, preferences: cluster.preferences || {} }); + store.set(contextName, { kubeConfig: cluster.kubeConfig, icon: cluster.icon || null, preferences: cluster.preferences || {}}); } } } as MigrationDeclaration; diff --git a/src/migrations/hotbar-store/5.0.0-alpha.0.ts b/src/migrations/hotbar-store/5.0.0-alpha.0.ts index 4ba145b662..016fd02671 100644 --- a/src/migrations/hotbar-store/5.0.0-alpha.0.ts +++ b/src/migrations/hotbar-store/5.0.0-alpha.0.ts @@ -28,9 +28,9 @@ export default { version: "5.0.0-alpha.0", run(store) { const hotbar = getEmptyHotbar("default"); - const { metadata: { uid, name, source } } = catalogEntity; + const { metadata: { uid, name, source }} = catalogEntity; - hotbar.items[0] = { entity: { uid, name, source } }; + hotbar.items[0] = { entity: { uid, name, source }}; store.set("hotbars", [hotbar]); } diff --git a/src/migrations/hotbar-store/5.0.0-beta.10.ts b/src/migrations/hotbar-store/5.0.0-beta.10.ts index e5691d3622..f915ac5619 100644 --- a/src/migrations/hotbar-store/5.0.0-beta.10.ts +++ b/src/migrations/hotbar-store/5.0.0-beta.10.ts @@ -53,9 +53,9 @@ export default { // Hotbars might be empty, if some of the previous migrations weren't run if (hotbars.length === 0) { const hotbar = getEmptyHotbar("default"); - const { metadata: { uid, name, source } } = catalogEntity; + const { metadata: { uid, name, source }} = catalogEntity; - hotbar.items[0] = { entity: { uid, name, source } }; + hotbar.items[0] = { entity: { uid, name, source }}; hotbars.push(hotbar); } @@ -132,7 +132,7 @@ export default { if (hotbars.every(hotbar => hotbar.items.every(item => item?.entity?.uid !== "catalog-entity"))) { // note, we will add a new whole hotbar here called "default" if that was previously removed const defaultHotbar = hotbars.find(hotbar => hotbar.name === "default"); - const { metadata: { uid, name, source } } = catalogEntity; + const { metadata: { uid, name, source }} = catalogEntity; if (defaultHotbar) { const freeIndex = defaultHotbar.items.findIndex(isNull); @@ -142,15 +142,15 @@ export default { // called "default" is full than overriding a hotbar item const hotbar = getEmptyHotbar("initial"); - hotbar.items[0] = { entity: { uid, name, source } }; + hotbar.items[0] = { entity: { uid, name, source }}; hotbars.unshift(hotbar); } else { - defaultHotbar.items[freeIndex] = { entity: { uid, name, source } }; + defaultHotbar.items[freeIndex] = { entity: { uid, name, source }}; } } else { const hotbar = getEmptyHotbar("default"); - hotbar.items[0] = { entity: { uid, name, source } }; + hotbar.items[0] = { entity: { uid, name, source }}; hotbars.unshift(hotbar); } } diff --git a/src/renderer/components/+apps-helm-charts/helm-chart-details.tsx b/src/renderer/components/+apps-helm-charts/helm-chart-details.tsx index 72a6f1ea34..997619bddd 100644 --- a/src/renderer/components/+apps-helm-charts/helm-chart-details.tsx +++ b/src/renderer/components/+apps-helm-charts/helm-chart-details.tsx @@ -91,7 +91,7 @@ export class HelmChartDetails extends Component { try { this.abortController?.abort(); this.abortController = new AbortController(); - const { chart: { name, repo } } = this.props; + const { chart: { name, repo }} = this.props; const { readme } = await getChartDetails(repo, name, { version: chart.version, reqInit: { signal: this.abortController.signal }}); this.readme = readme; diff --git a/src/renderer/components/+apps-helm-charts/helm-charts.tsx b/src/renderer/components/+apps-helm-charts/helm-charts.tsx index da5f9f8c5a..8b0930c180 100644 --- a/src/renderer/components/+apps-helm-charts/helm-charts.tsx +++ b/src/renderer/components/+apps-helm-charts/helm-charts.tsx @@ -50,7 +50,7 @@ export class HelmCharts extends Component { } get selectedChart() { - const { match: { params: { chartName, repo } } } = this.props; + const { match: { params: { chartName, repo }}} = this.props; return helmChartStore.getByName(chartName, repo); } diff --git a/src/renderer/components/+apps-releases/releases.tsx b/src/renderer/components/+apps-releases/releases.tsx index b7777b8c67..1c8790d9a3 100644 --- a/src/renderer/components/+apps-releases/releases.tsx +++ b/src/renderer/components/+apps-releases/releases.tsx @@ -55,7 +55,7 @@ interface Props extends RouteComponentProps { @observer export class HelmReleases extends Component { componentDidMount() { - const { match: { params: { namespace } } } = this.props; + const { match: { params: { namespace }}} = this.props; if (namespace) { namespaceStore.selectNamespaces(namespace); @@ -68,7 +68,7 @@ export class HelmReleases extends Component { } get selectedRelease() { - const { match: { params: { name, namespace } } } = this.props; + const { match: { params: { name, namespace }}} = this.props; return releaseStore.items.find(release => { return release.getName() == name && release.getNs() == namespace; diff --git a/src/renderer/components/+catalog/catalog-entity.store.tsx b/src/renderer/components/+catalog/catalog-entity.store.tsx index 8bbc335010..d4a5dbbc36 100644 --- a/src/renderer/components/+catalog/catalog-entity.store.tsx +++ b/src/renderer/components/+catalog/catalog-entity.store.tsx @@ -52,7 +52,7 @@ export class CatalogEntityStore extends ItemStore this.entities, () => this.loadAll()), - reaction(() => this.activeCategory, () => this.loadAll(), { delay: 100}), + reaction(() => this.activeCategory, () => this.loadAll(), { delay: 100 }), ); } diff --git a/src/renderer/components/+catalog/catalog.tsx b/src/renderer/components/+catalog/catalog.tsx index 8b491ec765..6ca4af9423 100644 --- a/src/renderer/components/+catalog/catalog.tsx +++ b/src/renderer/components/+catalog/catalog.tsx @@ -109,7 +109,7 @@ export class Catalog extends React.Component { console.error(error); Notifications.error(

Unknown category: {routeTab}

); } - }, {fireImmediately: true}), + }, { fireImmediately: true }), ]); // If active category is filtered out, automatically switch to the first category @@ -169,7 +169,7 @@ export class Catalog extends React.Component { const activeCategory = this.categories.find(category => category.getId() === tabId); if (activeCategory) { - navigate(catalogURL({ params: {group: activeCategory.spec.group, kind: activeCategory.spec.names.kind }})); + navigate(catalogURL({ params: { group: activeCategory.spec.group, kind: activeCategory.spec.names.kind }})); } else { navigate(catalogURL({ params: { group: browseCatalogTab }})); } diff --git a/src/renderer/components/+catalog/hotbar-toggle-menu-item.tsx b/src/renderer/components/+catalog/hotbar-toggle-menu-item.tsx index 00f6f3600f..da89ff3f26 100644 --- a/src/renderer/components/+catalog/hotbar-toggle-menu-item.tsx +++ b/src/renderer/components/+catalog/hotbar-toggle-menu-item.tsx @@ -27,14 +27,17 @@ import type { CatalogEntity } from "../../api/catalog-entity"; export function HotbarToggleMenuItem(props: { entity: CatalogEntity, addContent: ReactNode, removeContent: ReactNode }) { const store = HotbarStore.getInstance(); - const add = () => store.addToHotbar(props.entity); - const remove = () => store.removeFromHotbar(props.entity.getId()); const [itemInHotbar, setItemInHotbar] = useState(store.isAddedToActive(props.entity)); return ( { - itemInHotbar ? remove() : add(); - setItemInHotbar(!itemInHotbar); + if (itemInHotbar) { + store.removeFromHotbar(props.entity.getId()); + setItemInHotbar(false); + } else { + store.addToHotbar(props.entity); + setItemInHotbar(true); + } }}> {itemInHotbar ? props.removeContent : props.addContent } diff --git a/src/renderer/components/+config-resource-quotas/resource-quota-details.tsx b/src/renderer/components/+config-resource-quotas/resource-quota-details.tsx index 29db4fda7f..97ad62123d 100644 --- a/src/renderer/components/+config-resource-quotas/resource-quota-details.tsx +++ b/src/renderer/components/+config-resource-quotas/resource-quota-details.tsx @@ -48,7 +48,7 @@ function transformUnit(name: string, value: string): number { } function renderQuotas(quota: ResourceQuota): JSX.Element[] { - const { hard = {}, used = {} } = quota.status; + const { hard = {}, used = {}} = quota.status; return Object.entries(hard) .filter(([name]) => used[name]) diff --git a/src/renderer/components/+custom-resources/crd-details.tsx b/src/renderer/components/+custom-resources/crd-details.tsx index 45fdda36bb..4f38dced3b 100644 --- a/src/renderer/components/+custom-resources/crd-details.tsx +++ b/src/renderer/components/+custom-resources/crd-details.tsx @@ -153,7 +153,7 @@ export class CRDDetails extends React.Component { {validation && <> - + } diff --git a/src/renderer/components/+custom-resources/crd-resource-details.tsx b/src/renderer/components/+custom-resources/crd-resource-details.tsx index 832cdf739c..9e322ad464 100644 --- a/src/renderer/components/+custom-resources/crd-resource-details.tsx +++ b/src/renderer/components/+custom-resources/crd-resource-details.tsx @@ -96,7 +96,7 @@ export class CrdResourceDetails extends React.Component { } render() { - const { props: { object, crd } } = this; + const { props: { object, crd }} = this; if (!object || !crd) { return null; diff --git a/src/renderer/components/+extensions/extensions.tsx b/src/renderer/components/+extensions/extensions.tsx index 46b7a26919..91e568bf7f 100644 --- a/src/renderer/components/+extensions/extensions.tsx +++ b/src/renderer/components/+extensions/extensions.tsx @@ -246,7 +246,7 @@ async function createTempFilesAndValidate({ fileName, dataP }: InstallRequest): } async function unpackExtension(request: InstallRequestValidated, disposeDownloading?: Disposer) { - const { id, fileName, tempFile, manifest: { name, version } } = request; + const { id, fileName, tempFile, manifest: { name, version }} = request; ExtensionInstallationStateStore.setInstalling(id); disposeDownloading?.(); @@ -386,7 +386,7 @@ async function attemptInstall(request: InstallRequest, d?: ExtendableDisposer): // install extension if not yet exists await unpackExtension(validatedRequest, dispose); } else { - const { manifest: { version: oldVersion } } = ExtensionLoader.getInstance().getExtension(validatedRequest.id); + const { manifest: { version: oldVersion }} = ExtensionLoader.getInstance().getExtension(validatedRequest.id); // otherwise confirmation required (re-install / update) const removeNotification = Notifications.info( @@ -451,7 +451,7 @@ async function installFromInput(input: string) { await attemptInstall({ fileName, dataP: readFileNotify(input) }); } else if (InputValidators.isExtensionNameInstall.validate(input)) { - const [{ groups: { name, version } }] = [...input.matchAll(InputValidators.isExtensionNameInstallRegex)]; + const [{ groups: { name, version }}] = [...input.matchAll(InputValidators.isExtensionNameInstallRegex)]; await attemptInstallByInfo({ name, version }); } diff --git a/src/renderer/components/+extensions/installed-extensions.tsx b/src/renderer/components/+extensions/installed-extensions.tsx index 0da09e5ec9..09c41aeefc 100644 --- a/src/renderer/components/+extensions/installed-extensions.tsx +++ b/src/renderer/components/+extensions/installed-extensions.tsx @@ -106,7 +106,7 @@ export const InstalledExtensions = observer(({ extensions, uninstall, enable, di ), version, status: ( -
+
{getStatus(extension)}
), diff --git a/src/renderer/components/+network-endpoints/endpoint-subset-list.tsx b/src/renderer/components/+network-endpoints/endpoint-subset-list.tsx index 7dcb1fc99b..aa4226f06a 100644 --- a/src/renderer/components/+network-endpoints/endpoint-subset-list.tsx +++ b/src/renderer/components/+network-endpoints/endpoint-subset-list.tsx @@ -23,7 +23,7 @@ import "./endpoint-subset-list.scss"; import React from "react"; import { observer } from "mobx-react"; -import { EndpointSubset, Endpoint, EndpointAddress} from "../../../common/k8s-api/endpoints"; +import { EndpointSubset, Endpoint, EndpointAddress } from "../../../common/k8s-api/endpoints"; import { Table, TableCell, TableHead, TableRow } from "../table"; import { boundMethod } from "../../utils"; import { apiManager } from "../../../common/k8s-api/api-manager"; @@ -47,7 +47,7 @@ export class EndpointSubsetList extends React.Component { @boundMethod getNotReadyAddressTableRow(ip: string) { - const { subset} = this.props; + const { subset } = this.props; const address = subset.getNotReadyAddresses().find(address => address.getId() == ip); return this.renderAddressTableRow(address); diff --git a/src/renderer/components/+network-ingresses/ingress-details.tsx b/src/renderer/components/+network-ingresses/ingress-details.tsx index 76515250b2..a0ec3ce8ca 100644 --- a/src/renderer/components/+network-ingresses/ingress-details.tsx +++ b/src/renderer/components/+network-ingresses/ingress-details.tsx @@ -62,7 +62,7 @@ export class IngressDetails extends React.Component { } renderPaths(ingress: Ingress) { - const { spec: { rules } } = ingress; + const { spec: { rules }} = ingress; if (!rules || !rules.length) return null; diff --git a/src/renderer/components/+network-policies/network-policy-details.tsx b/src/renderer/components/+network-policies/network-policy-details.tsx index 2ce5fc9034..b7105a1ff3 100644 --- a/src/renderer/components/+network-policies/network-policy-details.tsx +++ b/src/renderer/components/+network-policies/network-policy-details.tsx @@ -95,7 +95,7 @@ export class NetworkPolicyDetails extends React.Component { <> {to.map(item => { - const { ipBlock: { cidr, except } = {} } = item; + const { ipBlock: { cidr, except } = {}} = item; if (!cidr) return null; diff --git a/src/renderer/components/+network-port-forwards/port-forwards.tsx b/src/renderer/components/+network-port-forwards/port-forwards.tsx index 17b1c40c20..cafa96b4c0 100644 --- a/src/renderer/components/+network-port-forwards/port-forwards.tsx +++ b/src/renderer/components/+network-port-forwards/port-forwards.tsx @@ -54,7 +54,7 @@ export class PortForwards extends React.Component { } get selectedPortForward() { - const { match: { params: { forwardport } } } = this.props; + const { match: { params: { forwardport }}} = this.props; return portForwardStore.getById(forwardport); } diff --git a/src/renderer/components/+network-services/service-details.tsx b/src/renderer/components/+network-services/service-details.tsx index 5948765089..d247e7908c 100644 --- a/src/renderer/components/+network-services/service-details.tsx +++ b/src/renderer/components/+network-services/service-details.tsx @@ -67,6 +67,11 @@ export class ServiceDetails extends React.Component { const { spec } = service; const endpoint = endpointStore.getByName(service.getName(), service.getNs()); + const externalIps = service.getExternalIps(); + + if (externalIps.length === 0 && spec?.externalName) { + externalIps.push(spec.externalName); + } return (
@@ -106,9 +111,9 @@ export class ServiceDetails extends React.Component { {service.getIpFamilyPolicy()} - {service.getExternalIps().length > 0 && ( + {externalIps.length > 0 && ( - {service.getExternalIps().map(ip =>
{ip}
)} + {externalIps.map(ip =>
{ip}
)}
)} diff --git a/src/renderer/components/+network-services/services.tsx b/src/renderer/components/+network-services/services.tsx index fe3b2b40ab..e29cc737cd 100644 --- a/src/renderer/components/+network-services/services.tsx +++ b/src/renderer/components/+network-services/services.tsx @@ -81,18 +81,26 @@ export class Services extends React.Component { { title: "Age", className: "age", sortBy: columnId.age, id: columnId.age }, { title: "Status", className: "status", sortBy: columnId.status, id: columnId.status }, ]} - renderTableContents={service => [ - service.getName(), - , - service.getNs(), - service.getType(), - service.getClusterIp(), - service.getPorts().join(", "), - service.getExternalIps().join(", ") || "-", - service.getSelector().map(label => ), - service.getAge(), - { title: service.getStatus(), className: service.getStatus().toLowerCase() }, - ]} + renderTableContents={service => { + const externalIps = service.getExternalIps(); + + if (externalIps.length === 0 && service.spec?.externalName) { + externalIps.push(service.spec.externalName); + } + + return [ + service.getName(), + , + service.getNs(), + service.getType(), + service.getClusterIp(), + service.getPorts().join(", "), + externalIps.join(", ") || "-", + service.getSelector().map(label => ), + service.getAge(), + { title: service.getStatus(), className: service.getStatus().toLowerCase() }, + ]; + }} /> ); } diff --git a/src/renderer/components/+preferences/add-helm-repo-dialog.tsx b/src/renderer/components/+preferences/add-helm-repo-dialog.tsx index 8ec68dc395..474ec54491 100644 --- a/src/renderer/components/+preferences/add-helm-repo-dialog.tsx +++ b/src/renderer/components/+preferences/add-helm-repo-dialog.tsx @@ -53,7 +53,7 @@ const dialogState = observable.object({ @observer export class AddHelmRepoDialog extends React.Component { - private emptyRepo = {name: "", url: "", username: "", password: "", insecureSkipTlsVerify: false, caFile:"", keyFile: "", certFile: ""}; + private emptyRepo = { name: "", url: "", username: "", password: "", insecureSkipTlsVerify: false, caFile:"", keyFile: "", certFile: "" }; private static keyExtensions = ["key", "keystore", "jks", "p12", "pfx", "pem"]; private static certExtensions = ["crt", "cer", "ca-bundle", "p7b", "p7c" , "p7s", "p12", "pfx", "pem"]; @@ -96,7 +96,7 @@ export class AddHelmRepoDialog extends React.Component { buttonLabel: `Use file`, filters: [ fileFilter, - { name: "Any", extensions: ["*"]} + { name: "Any", extensions: ["*"] } ] }); @@ -128,7 +128,7 @@ export class AddHelmRepoDialog extends React.Component { /> this.selectFileDialog(fileType, {name: placeholder, extensions: fileExtensions})} + onClick={() => this.selectFileDialog(fileType, { name: placeholder, extensions: fileExtensions })} tooltip="Browse" />
); diff --git a/src/renderer/components/+preferences/kubeconfig-syncs.tsx b/src/renderer/components/+preferences/kubeconfig-syncs.tsx index 35b3d88b04..e517494f04 100644 --- a/src/renderer/components/+preferences/kubeconfig-syncs.tsx +++ b/src/renderer/components/+preferences/kubeconfig-syncs.tsx @@ -46,7 +46,7 @@ interface Value { info: SyncInfo; } -async function getMapEntry({ filePath, ...data}: KubeconfigSyncEntry): Promise<[string, Value]> { +async function getMapEntry({ filePath, ...data }: KubeconfigSyncEntry): Promise<[string, Value]> { try { // stat follows the stat(2) linux syscall spec, namely it follows symlinks const stats = await fse.stat(filePath); diff --git a/src/renderer/components/+preferences/preferences.tsx b/src/renderer/components/+preferences/preferences.tsx index 2abed711e6..2b1a536b9f 100644 --- a/src/renderer/components/+preferences/preferences.tsx +++ b/src/renderer/components/+preferences/preferences.tsx @@ -106,7 +106,7 @@ export class Preferences extends React.Component { } } -export function ExtensionSettings({ title, id, components: { Hint, Input } }: RegisteredAppPreference) { +export function ExtensionSettings({ title, id, components: { Hint, Input }}: RegisteredAppPreference) { return (
diff --git a/src/renderer/components/+preferences/removable-item.tsx b/src/renderer/components/+preferences/removable-item.tsx index 19164746fa..131974f4d1 100644 --- a/src/renderer/components/+preferences/removable-item.tsx +++ b/src/renderer/components/+preferences/removable-item.tsx @@ -31,7 +31,7 @@ interface Props extends DOMAttributes{ className?: string; } -export function RemovableItem({icon, onRemove, children, className, ...rest}: Props) { +export function RemovableItem({ icon, onRemove, children, className, ...rest }: Props) { return (
{icon && ( diff --git a/src/renderer/components/+user-management/+service-accounts/details.tsx b/src/renderer/components/+user-management/+service-accounts/details.tsx index ee19079c40..ce1352f705 100644 --- a/src/renderer/components/+user-management/+service-accounts/details.tsx +++ b/src/renderer/components/+user-management/+service-accounts/details.tsx @@ -59,7 +59,7 @@ export class ServiceAccountsDetails extends React.Component { }); this.secrets = await Promise.all(secrets); - const imagePullSecrets = serviceAccount.getImagePullSecrets().map(async({ name }) => { + const imagePullSecrets = serviceAccount.getImagePullSecrets().map(async ({ name }) => { return secretsStore.load({ name, namespace }).catch(() => this.generateDummySecretObject(name)); }); diff --git a/src/renderer/components/+workloads-deployments/deployment-scale-dialog.test.tsx b/src/renderer/components/+workloads-deployments/deployment-scale-dialog.test.tsx index 3bc22b8263..2c6d3d9592 100644 --- a/src/renderer/components/+workloads-deployments/deployment-scale-dialog.test.tsx +++ b/src/renderer/components/+workloads-deployments/deployment-scale-dialog.test.tsx @@ -39,7 +39,7 @@ const dummyDeployment: Deployment = { selfLink: "link", spec: { replicas: 1, - selector: { matchLabels: { dummy: "label" } }, + selector: { matchLabels: { dummy: "label" }}, template: { metadata: { labels: { dummy: "label" }, diff --git a/src/renderer/components/+workloads-deployments/deployment-scale-dialog.tsx b/src/renderer/components/+workloads-deployments/deployment-scale-dialog.tsx index f4dec0a9b9..7c9d3ed9d7 100644 --- a/src/renderer/components/+workloads-deployments/deployment-scale-dialog.tsx +++ b/src/renderer/components/+workloads-deployments/deployment-scale-dialog.tsx @@ -118,12 +118,14 @@ export class DeploymentScaleDialog extends Component { } }; + private readonly scaleMin = 0; + desiredReplicasUp = () => { - this.desiredReplicas < this.scaleMax && this.desiredReplicas++; + this.desiredReplicas = Math.min(this.scaleMax, this.desiredReplicas + 1); }; desiredReplicasDown = () => { - this.desiredReplicas > 0 && this.desiredReplicas--; + this.desiredReplicas = Math.max(this.scaleMin, this.desiredReplicas - 1); }; renderContents() { diff --git a/src/renderer/components/+workloads-pods/pod-container-env.tsx b/src/renderer/components/+workloads-pods/pod-container-env.tsx index 4c847e68bb..0ed594b580 100644 --- a/src/renderer/components/+workloads-pods/pod-container-env.tsx +++ b/src/renderer/components/+workloads-pods/pod-container-env.tsx @@ -40,30 +40,23 @@ interface Props { export const ContainerEnvironment = observer((props: Props) => { const { container: { env, envFrom }, namespace } = props; - useEffect( - () => - autorun(() => { - env && env.forEach(variable => { - const { valueFrom } = variable; + useEffect( () => autorun(() => { + for (const { valueFrom } of env ?? []) { + if (valueFrom?.configMapKeyRef) { + configMapsStore.load({ name: valueFrom.configMapKeyRef.name, namespace }); + } + } - if (valueFrom && valueFrom.configMapKeyRef) { - configMapsStore.load({ name: valueFrom.configMapKeyRef.name, namespace }); - } - }); - envFrom && envFrom.forEach(item => { - const { configMapRef, secretRef } = item; + for (const { configMapRef, secretRef } of envFrom ?? []) { + if (secretRef?.name) { + secretsStore.load({ name: secretRef.name, namespace }); + } - if (secretRef && secretRef.name) { - secretsStore.load({ name: secretRef.name, namespace }); - } - - if (configMapRef && configMapRef.name) { - configMapsStore.load({ name: configMapRef.name, namespace }); - } - }); - }), - [] - ); + if (configMapRef?.name) { + configMapsStore.load({ name: configMapRef.name, namespace }); + } + } + }), []); const renderEnv = () => { const orderedEnv = _.sortBy(env, "name"); diff --git a/src/renderer/components/+workloads-pods/pod-details-affinities.tsx b/src/renderer/components/+workloads-pods/pod-details-affinities.tsx index 81660ca965..e42c870ece 100644 --- a/src/renderer/components/+workloads-pods/pod-details-affinities.tsx +++ b/src/renderer/components/+workloads-pods/pod-details-affinities.tsx @@ -41,7 +41,7 @@ export class PodDetailsAffinities extends React.Component {
- +
diff --git a/src/renderer/components/+workloads-replicasets/replicaset-scale-dialog.tsx b/src/renderer/components/+workloads-replicasets/replicaset-scale-dialog.tsx index 3fda576d0e..01a187e1d8 100644 --- a/src/renderer/components/+workloads-replicasets/replicaset-scale-dialog.tsx +++ b/src/renderer/components/+workloads-replicasets/replicaset-scale-dialog.tsx @@ -118,12 +118,14 @@ export class ReplicaSetScaleDialog extends Component { } }; + private readonly scaleMin = 0; + desiredReplicasUp = () => { - this.desiredReplicas < this.scaleMax && this.desiredReplicas++; + this.desiredReplicas = Math.min(this.scaleMax, this.desiredReplicas + 1); }; desiredReplicasDown = () => { - this.desiredReplicas > 0 && this.desiredReplicas--; + this.desiredReplicas = Math.max(this.scaleMin, this.desiredReplicas - 1); }; renderContents() { diff --git a/src/renderer/components/+workloads-statefulsets/statefulset-scale-dialog.tsx b/src/renderer/components/+workloads-statefulsets/statefulset-scale-dialog.tsx index 7fb49fabbe..81f7abf149 100644 --- a/src/renderer/components/+workloads-statefulsets/statefulset-scale-dialog.tsx +++ b/src/renderer/components/+workloads-statefulsets/statefulset-scale-dialog.tsx @@ -117,12 +117,14 @@ export class StatefulSetScaleDialog extends Component { } }; + private readonly scaleMin = 0; + desiredReplicasUp = () => { - this.desiredReplicas < this.scaleMax && this.desiredReplicas++; + this.desiredReplicas = Math.min(this.scaleMax, this.desiredReplicas + 1); }; desiredReplicasDown = () => { - this.desiredReplicas > 0 && this.desiredReplicas--; + this.desiredReplicas = Math.max(this.scaleMin, this.desiredReplicas - 1); }; renderContents() { diff --git a/src/renderer/components/__tests__/deployments.store.test.ts b/src/renderer/components/__tests__/deployments.store.test.ts index 7742b55313..bb7afc5e07 100644 --- a/src/renderer/components/__tests__/deployments.store.test.ts +++ b/src/renderer/components/__tests__/deployments.store.test.ts @@ -60,7 +60,7 @@ const runningDeployment = new Deployment({ runningDeployment.spec = { replicas: 1, - selector: { matchLabels: {} }, + selector: { matchLabels: {}}, strategy: { type: "test", rollingUpdate: { @@ -91,7 +91,7 @@ const failedDeployment = new Deployment({ failedDeployment.spec = { replicas: 1, - selector: { matchLabels: {} }, + selector: { matchLabels: {}}, strategy: { type: "test", rollingUpdate: { @@ -122,7 +122,7 @@ const pendingDeployment = new Deployment({ pendingDeployment.spec = { replicas: 1, - selector: { matchLabels: {} }, + selector: { matchLabels: {}}, strategy: { type: "test", rollingUpdate: { diff --git a/src/renderer/components/cluster-manager/cluster-manager.tsx b/src/renderer/components/cluster-manager/cluster-manager.tsx index 2058707b99..97797ec68e 100644 --- a/src/renderer/components/cluster-manager/cluster-manager.tsx +++ b/src/renderer/components/cluster-manager/cluster-manager.tsx @@ -67,7 +67,7 @@ export class ClusterManager extends React.Component { { GlobalPageRegistry.getInstance().getItems() - .map(({ url, components: { Page } }) => ( + .map(({ url, components: { Page }}) => ( )) } diff --git a/src/renderer/components/cluster-settings/cluster-settings.tsx b/src/renderer/components/cluster-settings/cluster-settings.tsx index ce9822b26c..6c35c1bbc8 100644 --- a/src/renderer/components/cluster-settings/cluster-settings.tsx +++ b/src/renderer/components/cluster-settings/cluster-settings.tsx @@ -119,7 +119,7 @@ export function MetricsSettings({ entity }: EntitySettingViewProps) { ); } -export function NodeShellSettings({entity}: EntitySettingViewProps) { +export function NodeShellSettings({ entity }: EntitySettingViewProps) { const cluster = getClusterForEntity(entity); if(!cluster) { diff --git a/src/renderer/components/drawer/drawer.tsx b/src/renderer/components/drawer/drawer.tsx index 1249638d59..96ae67c4dc 100644 --- a/src/renderer/components/drawer/drawer.tsx +++ b/src/renderer/components/drawer/drawer.tsx @@ -109,7 +109,7 @@ export class Drawer extends React.Component { }; onClickOutside = (evt: MouseEvent) => { - const { contentElem, mouseDownTarget, close, props: { open } } = this; + const { contentElem, mouseDownTarget, close, props: { open }} = this; if (!open || evt.defaultPrevented || contentElem.contains(mouseDownTarget)) { return; @@ -139,9 +139,9 @@ export class Drawer extends React.Component { const k8sObjName = title.split(":")[1] || title; // copy whole if no : clipboard.writeText(k8sObjName.trim()); - this.setState({isCopied: true}); + this.setState({ isCopied: true }); setTimeout(() => { - this.setState({isCopied: false}); + this.setState({ isCopied: false }); }, 3000); }; diff --git a/src/renderer/components/hotbar/__tests__/hotbar-remove-command.test.tsx b/src/renderer/components/hotbar/__tests__/hotbar-remove-command.test.tsx index 2880aa12d6..0935f7d797 100644 --- a/src/renderer/components/hotbar/__tests__/hotbar-remove-command.test.tsx +++ b/src/renderer/components/hotbar/__tests__/hotbar-remove-command.test.tsx @@ -47,7 +47,7 @@ jest.mock("electron", () => ({ AppPaths.init(); -const mockHotbars: {[id: string]: any} = { +const mockHotbars: { [id: string]: any } = { "1": { id: "1", name: "Default", diff --git a/src/renderer/components/hotbar/hotbar-entity-icon.tsx b/src/renderer/components/hotbar/hotbar-entity-icon.tsx index b3ed9df942..75f5cb74c0 100644 --- a/src/renderer/components/hotbar/hotbar-entity-icon.tsx +++ b/src/renderer/components/hotbar/hotbar-entity-icon.tsx @@ -74,7 +74,7 @@ export class HotbarEntityIcon extends React.Component { return null; } - const className = cssNames("led", { online: this.props.entity.status.phase === LensKubernetesClusterStatus.CONNECTED}); // TODO: make it more generic + const className = cssNames("led", { online: this.props.entity.status.phase === LensKubernetesClusterStatus.CONNECTED }); // TODO: make it more generic return
; } diff --git a/src/renderer/components/hotbar/hotbar-icon.tsx b/src/renderer/components/hotbar/hotbar-icon.tsx index 176abcc996..64c914cad1 100644 --- a/src/renderer/components/hotbar/hotbar-icon.tsx +++ b/src/renderer/components/hotbar/hotbar-icon.tsx @@ -65,7 +65,7 @@ function onMenuItemClick(menuItem: CatalogEntityContextMenu) { } } -export const HotbarIcon = observer(({menuItems = [], size = 40, tooltip, ...props}: HotbarIconProps) => { +export const HotbarIcon = observer(({ menuItems = [], size = 40, tooltip, ...props }: HotbarIconProps) => { const { uid, title, src, material, active, className, source, disabled, onMenuOpen, onClick, children, ...rest } = props; const id = `hotbarIcon-${uid}`; const [menuOpen, setMenuOpen] = useState(false); @@ -104,7 +104,7 @@ export const HotbarIcon = observer(({menuItems = [], size = 40, tooltip, ...prop className="HotbarIconMenu" isOpen={menuOpen} toggleEvent="contextmenu" - position={{right: true, bottom: true }} // FIXME: position does not work + position={{ right: true, bottom: true }} // FIXME: position does not work open={() => { onMenuOpen?.(); toggleMenu(); diff --git a/src/renderer/components/kube-object-menu/kube-object-menu.tsx b/src/renderer/components/kube-object-menu/kube-object-menu.tsx index ac2a99cc88..300ce67775 100644 --- a/src/renderer/components/kube-object-menu/kube-object-menu.tsx +++ b/src/renderer/components/kube-object-menu/kube-object-menu.tsx @@ -89,7 +89,7 @@ export class KubeObjectMenu extends React.Component ( + .map(({ components: { MenuItem }}, index) => ( { > - +