From 2cef45dac273534756c1ddf244453538c8c862a5 Mon Sep 17 00:00:00 2001 From: Lauri Nevala Date: Fri, 25 Sep 2020 14:51:30 +0300 Subject: [PATCH] Migrate kubeconfig path only if file does not exist Signed-off-by: Lauri Nevala --- src/migrations/cluster-store/snap.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/migrations/cluster-store/snap.ts b/src/migrations/cluster-store/snap.ts index 9d5910e189..a377ba4268 100644 --- a/src/migrations/cluster-store/snap.ts +++ b/src/migrations/cluster-store/snap.ts @@ -3,6 +3,7 @@ import { migration } from "../migration-wrapper"; import { ClusterModel, ClusterStore } from "../../common/cluster-store"; import { getAppVersion } from "../../common/utils/app-version"; +import fs from "fs" export default migration({ version: getAppVersion(), // Run always after upgrade @@ -19,8 +20,10 @@ export default migration({ /** * replace snap version with 'current' in kubeconfig path */ - const kubeconfigPath = cluster.kubeConfigPath.replace(/\/snap\/kontena-lens\/[0-9]*\//, "/snap/kontena-lens/current/") - cluster.kubeConfigPath = kubeconfigPath + if (!fs.existsSync(cluster.kubeConfigPath)) { + const kubeconfigPath = cluster.kubeConfigPath.replace(/\/snap\/kontena-lens\/[0-9]*\//, "/snap/kontena-lens/current/") + cluster.kubeConfigPath = kubeconfigPath + } return cluster; })