Move cluster related types and function into seperate files (#3530)

This commit is contained in:
Sebastian Malton authored and GitHub committed 2021-08-03 10:36:14 -04:00
1 parent 2893ad956d
commit a6e91fc34a
49 files changed
+435 -258

No files matched your search

+4 -3
View File
@@ -25,9 +25,10 @@
import path from "path";
import { app } from "electron";
import fse from "fs-extra";
import { ClusterModel, ClusterStore } from "../../common/cluster-store";
import { loadConfigFromFileSync } from "../../common/kube-helpers";
import { MigrationDeclaration, migrationLog } from "../helpers";
import type { ClusterModel } from "../../common/cluster-types";
import { getCustomKubeConfigPath, storedKubeConfigFolder } from "../../common/utils";
interface Pre360ClusterModel extends ClusterModel {
kubeConfig: string;
@@ -40,7 +41,7 @@ export default {
const storedClusters: Pre360ClusterModel[] = store.get("clusters") ?? [];
const migratedClusters: ClusterModel[] = [];
fse.ensureDirSync(ClusterStore.storedKubeConfigFolder);
fse.ensureDirSync(storedKubeConfigFolder());
migrationLog("Number of clusters to migrate: ", storedClusters.length);
@@ -49,7 +50,7 @@ export default {
* migrate kubeconfig
*/
try {
const absPath = ClusterStore.getCustomKubeConfigPath(clusterModel.id);
const absPath = getCustomKubeConfigPath(clusterModel.id);
// take the embedded kubeconfig and dump it into a file
fse.writeFileSync(absPath, clusterModel.kubeConfig, { encoding: "utf-8", mode: 0o600 });
@@ -22,7 +22,7 @@
import path from "path";
import { app } from "electron";
import fse from "fs-extra";
import type { ClusterModel } from "../../common/cluster-store";
import type { ClusterModel } from "../../common/cluster-types";
import type { MigrationDeclaration } from "../helpers";
interface Pre500WorkspaceStoreModel {
@@ -19,7 +19,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import type { ClusterModel, ClusterPreferences, ClusterPrometheusPreferences } from "../../common/cluster-store";
import type { ClusterModel, ClusterPreferences, ClusterPrometheusPreferences } from "../../common/cluster-types";
import { MigrationDeclaration, migrationLog } from "../helpers";
import { generateNewIdFor } from "../utils";
import path from "path";
+1 -1
View File
@@ -21,7 +21,7 @@
// Fix embedded kubeconfig paths under snap config
import type { ClusterModel } from "../../common/cluster-store";
import type { ClusterModel } from "../../common/cluster-types";
import { getAppVersion } from "../../common/utils/app-version";
import fs from "fs";
import { MigrationDeclaration, migrationLog } from "../helpers";
+4 -4
View File
@@ -23,10 +23,10 @@ import { app } from "electron";
import { existsSync, readFileSync } from "fs";
import path from "path";
import os from "os";
import { ClusterStore, ClusterStoreModel } from "../../common/cluster-store";
import type { ClusterStoreModel } from "../../common/cluster-store";
import type { KubeconfigSyncEntry, UserPreferencesModel } from "../../common/user-store";
import { MigrationDeclaration, migrationLog } from "../helpers";
import { isLogicalChildPath } from "../../common/utils";
import { isLogicalChildPath, storedKubeConfigFolder } from "../../common/utils";
export default {
version: "5.0.3-beta.1",
@@ -42,8 +42,8 @@ export default {
for (const cluster of clusters) {
const dirOfKubeconfig = path.dirname(cluster.kubeConfigPath);
if (dirOfKubeconfig === ClusterStore.storedKubeConfigFolder) {
migrationLog(`Skipping ${cluster.id} because kubeConfigPath is under ClusterStore.storedKubeConfigFolder`);
if (dirOfKubeconfig === storedKubeConfigFolder()) {
migrationLog(`Skipping ${cluster.id} because kubeConfigPath is under the stored KubeConfig folder`);
continue;
}