mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Turn on strict mode in tsconfig.json
- Add route, clusterRoute, and payloadValidatedClusterRoute helper functions to improve types with backend routes - Turn on the following new lints: - react/jsx-first-prop-new-line - react/jsx-wrap-multilines - react/jsx-one-expression-per-line - react/jsx-max-props-per-line - react/jsx-indent - react/jsx-indent-props Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
e532b90b72
commit
f594bf03f3
689 files changed
+14529
-11302
No files matched your search
@@ -5,12 +5,14 @@
|
||||
|
||||
import type { KubeConfig } from "@kubernetes/client-node";
|
||||
import type { Cluster } from "../../common/cluster/cluster";
|
||||
import type { ContextHandler } from "../context-handler/context-handler";
|
||||
import type { ClusterContextHandler } from "../context-handler/context-handler";
|
||||
import path from "path";
|
||||
import fs from "fs-extra";
|
||||
import { dumpConfigYaml } from "../../common/kube-helpers";
|
||||
import logger from "../logger";
|
||||
import { LensProxy } from "../lens-proxy";
|
||||
import { isErrnoException } from "../../common/utils";
|
||||
import type { PartialDeep } from "type-fest";
|
||||
|
||||
interface Dependencies {
|
||||
directoryForTemp: string;
|
||||
@@ -26,7 +28,7 @@ export class KubeconfigManager {
|
||||
*/
|
||||
protected tempFilePath: string | null | undefined = null;
|
||||
|
||||
protected contextHandler: ContextHandler;
|
||||
protected readonly contextHandler: ClusterContextHandler;
|
||||
|
||||
constructor(private dependencies: Dependencies, protected cluster: Cluster) {
|
||||
this.contextHandler = cluster.contextHandler;
|
||||
@@ -42,7 +44,7 @@ export class KubeconfigManager {
|
||||
}
|
||||
|
||||
if (this.tempFilePath === null || !(await fs.pathExists(this.tempFilePath))) {
|
||||
await this.ensureFile();
|
||||
return await this.ensureFile();
|
||||
}
|
||||
|
||||
return this.tempFilePath;
|
||||
@@ -61,7 +63,7 @@ export class KubeconfigManager {
|
||||
try {
|
||||
await fs.unlink(this.tempFilePath);
|
||||
} catch (error) {
|
||||
if (error.code !== "ENOENT") {
|
||||
if (isErrnoException(error) && error.code !== "ENOENT") {
|
||||
throw error;
|
||||
}
|
||||
} finally {
|
||||
@@ -72,7 +74,8 @@ export class KubeconfigManager {
|
||||
protected async ensureFile() {
|
||||
try {
|
||||
await this.contextHandler.ensureServer();
|
||||
this.tempFilePath = await this.createProxyKubeconfig();
|
||||
|
||||
return this.tempFilePath = await this.createProxyKubeconfig();
|
||||
} catch (error) {
|
||||
throw Object.assign(new Error("Failed to creat temp config for auth-proxy"), { cause: error });
|
||||
}
|
||||
@@ -94,13 +97,12 @@ export class KubeconfigManager {
|
||||
`kubeconfig-${id}`,
|
||||
);
|
||||
const kubeConfig = await cluster.getKubeconfig();
|
||||
const proxyConfig: Partial<KubeConfig> = {
|
||||
const proxyConfig: PartialDeep<KubeConfig> = {
|
||||
currentContext: contextName,
|
||||
clusters: [
|
||||
{
|
||||
name: contextName,
|
||||
server: this.resolveProxyUrl,
|
||||
skipTLSVerify: undefined,
|
||||
},
|
||||
],
|
||||
users: [
|
||||
@@ -111,7 +113,7 @@ export class KubeconfigManager {
|
||||
user: "proxy",
|
||||
name: contextName,
|
||||
cluster: contextName,
|
||||
namespace: cluster.defaultNamespace || kubeConfig.getContextObject(contextName).namespace,
|
||||
namespace: cluster.defaultNamespace || kubeConfig.getContextObject(contextName)?.namespace,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user