From a88acc13c02fc9c53113603bcd07745272c99c39 Mon Sep 17 00:00:00 2001 From: Lauri Nevala Date: Fri, 22 Jan 2021 13:39:30 +0200 Subject: [PATCH] Extract ValidationOpts type Signed-off-by: Lauri Nevala --- src/common/kube-helpers.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/common/kube-helpers.ts b/src/common/kube-helpers.ts index 9442ef8891..1387d1aa1b 100644 --- a/src/common/kube-helpers.ts +++ b/src/common/kube-helpers.ts @@ -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);