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

Migrate kubeconfig path only if file does not exist

Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
Lauri Nevala 2020-09-25 14:51:30 +03:00
parent 9ac5f21cd4
commit 2cef45dac2

View File

@ -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;
})