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

Extract ValidationOpts type

Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
Lauri Nevala 2021-01-22 13:39:30 +02:00
parent 1b963b4473
commit a88acc13c0

View File

@ -7,6 +7,12 @@ import logger from "../main/logger";
import commandExists from "command-exists";
import { ExecValidationNotFoundError } from "./custom-errors";
export type KubeConfigValidationOpts = {
validateCluster?: boolean;
validateUser?: boolean;
validateExec?: boolean;
};
export const kubeConfigDefaultPath = path.join(os.homedir(), ".kube", "config");
function resolveTilde(filePath: string) {
@ -154,11 +160,11 @@ export function getNodeWarningConditions(node: V1Node) {
* Validates Context, User and Cluster sructs in given kubeconfig. Additionally this will validate
* the command passed to the exec substructure.
*/
export function validateKubeConfig (config: KubeConfig, contextName: string, validationOpts?: { validateCluster?: boolean, validateUser?: boolean, validateExec?: boolean}) {
export function validateKubeConfig (config: KubeConfig, contextName: string, validationOpts?: KubeConfigValidationOpts) {
// we only receive a single context, cluster & user object here so lets validate them as this
// will be called when we add a new cluster to Lens
const opts = validationOpts || {};
const { validateUser = true, validateCluster = true, validateExec = true } = opts;
const { validateUser = true, validateCluster = true, validateExec = true } = validationOpts || {};
const contextObject = config.getContextObject(contextName);