mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
drop old (< 3.0) cluster-store migrations
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
e862d5bf1d
commit
91d2d61be4
@ -1,24 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { MigrationDeclaration } from "../helpers";
|
||||
|
||||
/**
|
||||
* Early store format had the kubeconfig directly under context name, this moves
|
||||
* it under the kubeConfig key
|
||||
*/
|
||||
|
||||
export default {
|
||||
version: "2.0.0-beta.2",
|
||||
run(store) {
|
||||
for (const value of store) {
|
||||
const contextName = value[0];
|
||||
|
||||
// Looping all the keys gives out the store internal stuff too...
|
||||
if (contextName === "__internal__" || Object.prototype.hasOwnProperty.call(value[1], "kubeConfig")) continue;
|
||||
store.set(contextName, { kubeConfig: value[1] });
|
||||
}
|
||||
},
|
||||
} as MigrationDeclaration;
|
||||
@ -1,22 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { MigrationDeclaration } from "../helpers";
|
||||
|
||||
// Cleans up a store that had the state related data stored
|
||||
|
||||
export default {
|
||||
version: "2.4.1",
|
||||
run(store) {
|
||||
for (const value of store) {
|
||||
const contextName = value[0];
|
||||
|
||||
if (contextName === "__internal__") continue;
|
||||
const cluster = value[1];
|
||||
|
||||
store.set(contextName, { kubeConfig: cluster.kubeConfig, icon: cluster.icon || null, preferences: cluster.preferences || {}});
|
||||
}
|
||||
},
|
||||
} as MigrationDeclaration;
|
||||
@ -1,27 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
// Move cluster icon from root to preferences
|
||||
import type { MigrationDeclaration } from "../helpers";
|
||||
|
||||
export default {
|
||||
version: "2.6.0-beta.2",
|
||||
run(store) {
|
||||
for (const value of store) {
|
||||
const clusterKey = value[0];
|
||||
|
||||
if (clusterKey === "__internal__") continue;
|
||||
const cluster = value[1];
|
||||
|
||||
if (!cluster.preferences) cluster.preferences = {};
|
||||
|
||||
if (cluster.icon) {
|
||||
cluster.preferences.icon = cluster.icon;
|
||||
delete (cluster["icon"]);
|
||||
}
|
||||
store.set(clusterKey, { contextName: clusterKey, kubeConfig: value[1].kubeConfig, preferences: value[1].preferences });
|
||||
}
|
||||
},
|
||||
} as MigrationDeclaration;
|
||||
@ -1,53 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import yaml from "js-yaml";
|
||||
import { MigrationDeclaration, migrationLog } from "../helpers";
|
||||
|
||||
export default {
|
||||
version: "2.6.0-beta.3",
|
||||
run(store) {
|
||||
for (const value of store) {
|
||||
const clusterKey = value[0];
|
||||
|
||||
if (clusterKey === "__internal__") continue;
|
||||
const cluster = value[1];
|
||||
|
||||
if (!cluster.kubeConfig) continue;
|
||||
const config = yaml.load(cluster.kubeConfig);
|
||||
|
||||
if (!config || typeof config !== "object" || !Object.prototype.hasOwnProperty.call(config, "users")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const kubeConfig = config as Record<string, any>;
|
||||
const userObj = kubeConfig.users[0];
|
||||
|
||||
if (userObj) {
|
||||
const user = userObj.user;
|
||||
|
||||
if (user["auth-provider"] && user["auth-provider"].config) {
|
||||
const authConfig = user["auth-provider"].config;
|
||||
|
||||
if (authConfig["access-token"]) {
|
||||
authConfig["access-token"] = `${authConfig["access-token"]}`;
|
||||
}
|
||||
|
||||
if (authConfig.expiry) {
|
||||
authConfig.expiry = `${authConfig.expiry}`;
|
||||
}
|
||||
migrationLog(authConfig);
|
||||
user["auth-provider"].config = authConfig;
|
||||
kubeConfig.users = [{
|
||||
name: userObj.name,
|
||||
user,
|
||||
}];
|
||||
cluster.kubeConfig = yaml.dump(kubeConfig);
|
||||
store.set(clusterKey, cluster);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
} as MigrationDeclaration;
|
||||
@ -1,22 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
// Add existing clusters to "default" workspace
|
||||
import type { MigrationDeclaration } from "../helpers";
|
||||
|
||||
export default {
|
||||
version: "2.7.0-beta.0",
|
||||
run(store) {
|
||||
for (const value of store) {
|
||||
const clusterKey = value[0];
|
||||
|
||||
if (clusterKey === "__internal__") continue;
|
||||
const cluster = value[1];
|
||||
|
||||
cluster.workspace = "default";
|
||||
store.set(clusterKey, cluster);
|
||||
}
|
||||
},
|
||||
} as MigrationDeclaration;
|
||||
@ -1,35 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
// Add id for clusters and store them to array
|
||||
import { v4 as uuid } from "uuid";
|
||||
import type { MigrationDeclaration } from "../helpers";
|
||||
|
||||
export default {
|
||||
version: "2.7.0-beta.1",
|
||||
run(store) {
|
||||
const clusters: any[] = [];
|
||||
|
||||
for (const value of store) {
|
||||
const clusterKey = value[0];
|
||||
|
||||
if (clusterKey === "__internal__") continue;
|
||||
if (clusterKey === "clusters") continue;
|
||||
const cluster = value[1];
|
||||
|
||||
cluster.id = uuid();
|
||||
|
||||
if (!cluster.preferences.clusterName) {
|
||||
cluster.preferences.clusterName = clusterKey;
|
||||
}
|
||||
clusters.push(cluster);
|
||||
store.delete(clusterKey);
|
||||
}
|
||||
|
||||
if (clusters.length > 0) {
|
||||
store.set("clusters", clusters);
|
||||
}
|
||||
},
|
||||
} as MigrationDeclaration;
|
||||
@ -7,24 +7,12 @@
|
||||
|
||||
import { joinMigrations } from "../helpers";
|
||||
|
||||
import version200Beta2 from "./2.0.0-beta.2";
|
||||
import version241 from "./2.4.1";
|
||||
import version260Beta2 from "./2.6.0-beta.2";
|
||||
import version260Beta3 from "./2.6.0-beta.3";
|
||||
import version270Beta0 from "./2.7.0-beta.0";
|
||||
import version270Beta1 from "./2.7.0-beta.1";
|
||||
import version360Beta1 from "./3.6.0-beta.1";
|
||||
import version500Beta10 from "./5.0.0-beta.10";
|
||||
import version500Beta13 from "./5.0.0-beta.13";
|
||||
import snap from "./snap";
|
||||
|
||||
export default joinMigrations(
|
||||
version200Beta2,
|
||||
version241,
|
||||
version260Beta2,
|
||||
version260Beta3,
|
||||
version270Beta0,
|
||||
version270Beta1,
|
||||
version360Beta1,
|
||||
version500Beta10,
|
||||
version500Beta13,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user