project restructuring and initial refactoring

This commit is contained in:
Roman committed 2020-06-09 15:14:40 +03:00
1 parent 5af12bdbbd
commit aa0eca2dc4
807 files changed
+11848 -22947

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
/* Early store format had the kubeconfig directly under context name, this moves
it under the kubeConfig key */
export function migration(store: any) {
console.log("CLUSTER STORE, MIGRATION: 2.0.0-beta.2");
for (const value of store) {
const contextName = value[0];
// Looping all the keys gives out the store internal stuff too...
if(contextName === "__internal__" || value[1].hasOwnProperty('kubeConfig')) continue;
store.set(contextName, { kubeConfig: value[1] });
}
}
+11
View File
@@ -0,0 +1,11 @@
// Cleans up a store that had the state related data stored
export function migration(store: any) {
console.log("CLUSTER STORE, MIGRATION: 2.4.1");
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 || {} });
}
}
+15
View File
@@ -0,0 +1,15 @@
// Move cluster icon from root to preferences
export function migration(store: any) {
console.log("CLUSTER STORE, MIGRATION: 2.6.0-beta.2");
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 });
}
}
+35
View File
@@ -0,0 +1,35 @@
import * as yaml from "js-yaml"
// Convert access token and expiry from arrays into strings
export function migration(store: any) {
console.log("CLUSTER STORE, MIGRATION: 2.6.0-beta.3");
for (const value of store) {
const clusterKey = value[0];
if(clusterKey === "__internal__") continue
const cluster = value[1];
if(!cluster.kubeConfig) continue
const kubeConfig = yaml.safeLoad(cluster.kubeConfig)
if(!kubeConfig.hasOwnProperty('users')) continue
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}`
}
console.log(authConfig)
user["auth-provider"].config = authConfig
kubeConfig.users = [{
name: userObj.name,
user: user
}]
cluster.kubeConfig = yaml.safeDump(kubeConfig)
store.set(clusterKey, cluster)
}
}
}
}
+11
View File
@@ -0,0 +1,11 @@
// Add existing clusters to "default" workspace
export function migration(store: any) {
console.log("CLUSTER STORE, MIGRATION: 2.7.0-beta.0");
for (const value of store) {
const clusterKey = value[0];
if(clusterKey === "__internal__") continue
const cluster = value[1];
cluster.workspace = "default"
store.set(clusterKey, cluster)
}
}
+22
View File
@@ -0,0 +1,22 @@
// add id for clusters and store them to array
import { v4 as uuid } from "uuid"
export function migration(store: any) {
console.log("CLUSTER STORE, MIGRATION: 2.7.0-beta.1");
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)
}
}
+4
View File
@@ -0,0 +1,4 @@
// Add / reset "lastSeenAppVersion"
export function migration(store: any) {
store.set("lastSeenAppVersion", "0.0.0");
}