mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Sync kubeconfigs from catalog (#3573)
* Kubeconfig syncs from Catalog Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Allow to select directory to sync Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Convert Preferences to Route-based component Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Jump from notification to Preferences Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Adding navigateWithoutHistoryChange() method Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Cleaning up Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Fixing integration tests (no check for Telemetry tab) Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Fixing tests harder Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
1 parent
2760178196
commit
b7be3ae21a
22 files changed
+672
-317
No files matched your search
@@ -20,12 +20,11 @@
|
||||
*/
|
||||
|
||||
import { catalogCategoryRegistry } from "../catalog/catalog-category-registry";
|
||||
import { CatalogEntity, CatalogEntityActionContext, CatalogEntityAddMenuContext, CatalogEntityContextMenuContext, CatalogEntityMetadata, CatalogEntityStatus } from "../catalog";
|
||||
import { CatalogEntity, CatalogEntityActionContext, CatalogEntityContextMenuContext, CatalogEntityMetadata, CatalogEntityStatus } from "../catalog";
|
||||
import { clusterActivateHandler, clusterDeleteHandler, clusterDisconnectHandler } from "../cluster-ipc";
|
||||
import { ClusterStore } from "../cluster-store";
|
||||
import { requestMain } from "../ipc";
|
||||
import { CatalogCategory, CatalogCategorySpec } from "../catalog";
|
||||
import { addClusterURL } from "../routes";
|
||||
import { app } from "electron";
|
||||
import type { CatalogEntitySpec } from "../catalog/catalog-entity";
|
||||
import { HotbarStore } from "../hotbar-store";
|
||||
@@ -43,7 +42,6 @@ export interface KubernetesClusterPrometheusMetrics {
|
||||
export interface KubernetesClusterSpec extends CatalogEntitySpec {
|
||||
kubeconfigPath: string;
|
||||
kubeconfigContext: string;
|
||||
accessibleNamespaces?: string[];
|
||||
metrics?: {
|
||||
source: string;
|
||||
prometheus?: KubernetesClusterPrometheusMetrics;
|
||||
@@ -149,7 +147,7 @@ export class KubernetesCluster extends CatalogEntity<KubernetesClusterMetadata,
|
||||
}
|
||||
}
|
||||
|
||||
export class KubernetesClusterCategory extends CatalogCategory {
|
||||
class KubernetesClusterCategory extends CatalogCategory {
|
||||
public readonly apiVersion = "catalog.k8slens.dev/v1alpha1";
|
||||
public readonly kind = "CatalogCategory";
|
||||
public metadata = {
|
||||
@@ -168,20 +166,8 @@ export class KubernetesClusterCategory extends CatalogCategory {
|
||||
kind: "KubernetesCluster"
|
||||
}
|
||||
};
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.on("catalogAddMenu", (ctx: CatalogEntityAddMenuContext) => {
|
||||
ctx.menuItems.push({
|
||||
icon: "text_snippet",
|
||||
title: "Add from kubeconfig",
|
||||
onClick: () => {
|
||||
ctx.navigate(addClusterURL());
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
catalogCategoryRegistry.add(new KubernetesClusterCategory());
|
||||
export const kubernetesClusterCategory = new KubernetesClusterCategory();
|
||||
|
||||
catalogCategoryRegistry.add(kubernetesClusterCategory);
|
||||
@@ -123,6 +123,7 @@ export interface CatalogEntityContextMenu {
|
||||
|
||||
export interface CatalogEntityAddMenu extends CatalogEntityContextMenu {
|
||||
icon: string;
|
||||
defaultAction?: boolean;
|
||||
}
|
||||
|
||||
export interface CatalogEntitySettingsMenu {
|
||||
|
||||
@@ -26,4 +26,29 @@ export const preferencesRoute: RouteProps = {
|
||||
path: "/preferences"
|
||||
};
|
||||
|
||||
export const appRoute: RouteProps = {
|
||||
path: `${preferencesRoute.path}/app`
|
||||
};
|
||||
|
||||
export const proxyRoute: RouteProps = {
|
||||
path: `${preferencesRoute.path}/proxy`
|
||||
};
|
||||
|
||||
export const kubernetesRoute: RouteProps = {
|
||||
path: `${preferencesRoute.path}/kubernetes`
|
||||
};
|
||||
|
||||
export const telemetryRoute: RouteProps = {
|
||||
path: `${preferencesRoute.path}/telemetry`
|
||||
};
|
||||
|
||||
export const extensionRoute: RouteProps = {
|
||||
path: `${preferencesRoute.path}/extensions`
|
||||
};
|
||||
|
||||
export const preferencesURL = buildURL(preferencesRoute.path);
|
||||
export const appURL = buildURL(appRoute.path);
|
||||
export const proxyURL = buildURL(proxyRoute.path);
|
||||
export const kubernetesURL = buildURL(kubernetesRoute.path);
|
||||
export const telemetryURL = buildURL(telemetryRoute.path);
|
||||
export const extensionURL = buildURL(extensionRoute.path);
|
||||
@@ -213,6 +213,6 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
|
||||
* Getting default directory to download kubectl binaries
|
||||
* @returns string
|
||||
*/
|
||||
export function getDefaultKubectlPath(): string {
|
||||
export function getDefaultKubectlDownloadPath(): string {
|
||||
return path.join((app || remote.app).getPath("userData"), "binaries");
|
||||
}
|
||||
@@ -21,6 +21,12 @@
|
||||
|
||||
import { action, ObservableMap } from "mobx";
|
||||
|
||||
export function multiSet<T, V>(map: Map<T, V>, newEntries: [T, V][]): void {
|
||||
for (const [key, val] of newEntries) {
|
||||
map.set(key, val);
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtendedMap<K, V> extends Map<K, V> {
|
||||
static new<K, V>(entries?: readonly (readonly [K, V])[] | null): ExtendedMap<K, V> {
|
||||
return new ExtendedMap<K, V>(entries);
|
||||
|
||||
Reference in new issue
Block a user