From 67c7c454bbe0d685ec4c754b3d53332032f31df6 Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Mon, 21 Jun 2021 09:27:13 +0300 Subject: [PATCH] Adding general entities throught initializers Signed-off-by: Alex Andreev --- src/main/catalog-sources/general.ts | 2 +- src/main/catalog-sources/index.ts | 1 + src/main/index.ts | 5 ++--- src/main/initializers/general-entities.ts | 22 ++++++++++++++++++++++ src/main/initializers/index.ts | 1 + 5 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 src/main/initializers/general-entities.ts diff --git a/src/main/catalog-sources/general.ts b/src/main/catalog-sources/general.ts index 20ad16d331..9f64f46b6d 100644 --- a/src/main/catalog-sources/general.ts +++ b/src/main/catalog-sources/general.ts @@ -67,6 +67,6 @@ const generalEntities = observable([ preferencesEntity ]); -export function addGeneralEntities() { +export function initializeGeneralEntities() { catalogEntityRegistry.addObservableSource("lens:general", generalEntities); } diff --git a/src/main/catalog-sources/index.ts b/src/main/catalog-sources/index.ts index 81f0182ca7..17f383185b 100644 --- a/src/main/catalog-sources/index.ts +++ b/src/main/catalog-sources/index.ts @@ -21,3 +21,4 @@ export { initializeWeblinks } from "./weblinks"; export { KubeconfigSyncManager } from "./kubeconfig-sync"; +export { initializeGeneralEntities } from "./general"; diff --git a/src/main/index.ts b/src/main/index.ts index ab8d3810e1..d9013cf1ba 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -53,7 +53,6 @@ import { handleWsUpgrade } from "./proxy/ws-upgrade"; import configurePackages from "../common/configure-packages"; import { PrometheusProviderRegistry } from "./prometheus"; import * as initializers from "./initializers"; -import { addGeneralEntities } from "./catalog-sources/general"; const workingDir = path.join(app.getPath("appData"), appName); const cleanup = disposer(); @@ -133,7 +132,7 @@ app.on("ready", async () => { handleWsUpgrade, req => ClusterManager.getInstance().getClusterForRequest(req), ); - + ClusterManager.createInstance().init(); KubeconfigSyncManager.createInstance(); @@ -183,7 +182,7 @@ app.on("ready", async () => { ipcMainOn(IpcRendererNavigationEvents.LOADED, () => { cleanup.push(pushCatalogToRenderer(catalogEntityRegistry)); KubeconfigSyncManager.getInstance().startSync(); - addGeneralEntities(); + initializers.initializeGeneralEntities(); startUpdateChecking(); LensProtocolRouterMain.getInstance().rendererLoaded = true; }); diff --git a/src/main/initializers/general-entities.ts b/src/main/initializers/general-entities.ts new file mode 100644 index 0000000000..b2e39d8a39 --- /dev/null +++ b/src/main/initializers/general-entities.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2021 OpenLens Authors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +export { initializeGeneralEntities } from "../catalog-sources"; diff --git a/src/main/initializers/index.ts b/src/main/initializers/index.ts index 37ff00bd77..6cd9330bac 100644 --- a/src/main/initializers/index.ts +++ b/src/main/initializers/index.ts @@ -24,3 +24,4 @@ export * from "./metrics-providers"; export * from "./ipc"; export * from "./weblinks"; export * from "./stores"; +export * from "./general-entities";