mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
wip: catalog helm repos
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
538c6c2013
commit
6ae42af9ff
83
src/common/catalog-entities/helm-repository.ts
Normal file
83
src/common/catalog-entities/helm-repository.ts
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { CatalogCategory, CatalogEntity, CatalogEntityContextMenuContext, CatalogEntityMetadata, CatalogEntityStatus } from "../catalog";
|
||||||
|
import { catalogCategoryRegistry } from "../catalog/catalog-category-registry";
|
||||||
|
|
||||||
|
export interface HelmRepositoryStatus extends CatalogEntityStatus {
|
||||||
|
phase: "available" | "unavailable";
|
||||||
|
}
|
||||||
|
|
||||||
|
export type HelmRepositorySpec = {
|
||||||
|
url: string;
|
||||||
|
id?: string;
|
||||||
|
digest?: string;
|
||||||
|
cacheFilePath?: string
|
||||||
|
caFile?: string,
|
||||||
|
certFile?: string,
|
||||||
|
insecureSkipTlsVerify?: boolean,
|
||||||
|
keyFile?: string,
|
||||||
|
username?: string,
|
||||||
|
password?: string,
|
||||||
|
icon?: {
|
||||||
|
src: string
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export class HelmRepository extends CatalogEntity<CatalogEntityMetadata, HelmRepositoryStatus, HelmRepositorySpec> {
|
||||||
|
public readonly apiVersion = "entity.k8slens.dev/v1alpha1";
|
||||||
|
public readonly kind = "HelmRepository";
|
||||||
|
|
||||||
|
async onRun() {
|
||||||
|
window.open(this.spec.url, "_blank");
|
||||||
|
}
|
||||||
|
|
||||||
|
public onSettingsOpen(): void {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async onContextMenuOpen(context: CatalogEntityContextMenuContext) {
|
||||||
|
// todo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class HelmRepositoryCategory extends CatalogCategory {
|
||||||
|
public readonly apiVersion = "catalog.k8slens.dev/v1alpha1";
|
||||||
|
public readonly kind = "CatalogCategory";
|
||||||
|
public metadata = {
|
||||||
|
name: "Helm Repositories",
|
||||||
|
icon: "apps"
|
||||||
|
};
|
||||||
|
public spec = {
|
||||||
|
group: "entity.k8slens.dev",
|
||||||
|
versions: [
|
||||||
|
{
|
||||||
|
name: "v1alpha1",
|
||||||
|
entityClass: HelmRepository
|
||||||
|
}
|
||||||
|
],
|
||||||
|
names: {
|
||||||
|
kind: "HelmRepository"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
catalogCategoryRegistry.add(new HelmRepositoryCategory());
|
||||||
1
src/common/catalog-entities/icons/helm.svg
Normal file
1
src/common/catalog-entities/icons/helm.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 5.5 KiB |
@ -22,3 +22,4 @@
|
|||||||
export * from "./general";
|
export * from "./general";
|
||||||
export * from "./kubernetes-cluster";
|
export * from "./kubernetes-cluster";
|
||||||
export * from "./web-link";
|
export * from "./web-link";
|
||||||
|
export * from "./helm-repository";
|
||||||
|
|||||||
@ -59,6 +59,8 @@ export type KubernetesClusterStatusPhase = "connected" | "connecting" | "disconn
|
|||||||
|
|
||||||
export interface KubernetesClusterStatus extends CatalogEntityStatus {
|
export interface KubernetesClusterStatus extends CatalogEntityStatus {
|
||||||
phase: KubernetesClusterStatusPhase;
|
phase: KubernetesClusterStatusPhase;
|
||||||
|
clusterVersion?: string;
|
||||||
|
clientVersion?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class KubernetesCluster extends CatalogEntity<CatalogEntityMetadata, KubernetesClusterStatus, KubernetesClusterSpec> {
|
export class KubernetesCluster extends CatalogEntity<CatalogEntityMetadata, KubernetesClusterStatus, KubernetesClusterSpec> {
|
||||||
|
|||||||
62
src/main/catalog-sources/helm-repositories.ts
Normal file
62
src/main/catalog-sources/helm-repositories.ts
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { observable } from "mobx";
|
||||||
|
import { HelmRepository } from "../../common/catalog-entities";
|
||||||
|
import { catalogEntityRegistry } from "../catalog";
|
||||||
|
import { HelmRepoManager } from "../helm/helm-repo-manager";
|
||||||
|
|
||||||
|
export function syncHelmRepositories() {
|
||||||
|
const repos = observable.array([]);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
HelmRepoManager.loadAvailableRepos().then((helmRepos) => {
|
||||||
|
repos.replace(helmRepos.map((helmRepo) => {
|
||||||
|
const labels: Record<string, string> = {};
|
||||||
|
|
||||||
|
if (helmRepo.verifiedPublisher) {
|
||||||
|
labels["verified-publisher"] = "true";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (helmRepo.official) {
|
||||||
|
labels["official"] = "true";
|
||||||
|
}
|
||||||
|
|
||||||
|
return new HelmRepository({
|
||||||
|
metadata: {
|
||||||
|
uid: helmRepo.id || helmRepo.url,
|
||||||
|
name: helmRepo.name,
|
||||||
|
source: "ArtifactHub.io",
|
||||||
|
labels
|
||||||
|
},
|
||||||
|
spec: {
|
||||||
|
...helmRepo
|
||||||
|
},
|
||||||
|
status: {
|
||||||
|
phase: "available"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
|
catalogEntityRegistry.addObservableSource("helm-repositories", repos);
|
||||||
|
}
|
||||||
@ -22,3 +22,4 @@
|
|||||||
export { syncWeblinks } from "./weblinks";
|
export { syncWeblinks } from "./weblinks";
|
||||||
export { KubeconfigSyncManager } from "./kubeconfig-sync";
|
export { KubeconfigSyncManager } from "./kubeconfig-sync";
|
||||||
export { syncGeneralEntities } from "./general";
|
export { syncGeneralEntities } from "./general";
|
||||||
|
export { syncHelmRepositories } from "./helm-repositories";
|
||||||
|
|||||||
@ -40,6 +40,8 @@ export interface HelmRepoConfig {
|
|||||||
export interface HelmRepo {
|
export interface HelmRepo {
|
||||||
name: string;
|
name: string;
|
||||||
url: string;
|
url: string;
|
||||||
|
id?: string;
|
||||||
|
digest?: string;
|
||||||
cacheFilePath?: string
|
cacheFilePath?: string
|
||||||
caFile?: string,
|
caFile?: string,
|
||||||
certFile?: string,
|
certFile?: string,
|
||||||
@ -47,6 +49,9 @@ export interface HelmRepo {
|
|||||||
keyFile?: string,
|
keyFile?: string,
|
||||||
username?: string,
|
username?: string,
|
||||||
password?: string,
|
password?: string,
|
||||||
|
verifiedPublisher?: boolean,
|
||||||
|
official?: boolean,
|
||||||
|
lastScanned?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export class HelmRepoManager extends Singleton {
|
export class HelmRepoManager extends Singleton {
|
||||||
@ -64,7 +69,21 @@ export class HelmRepoManager extends Singleton {
|
|||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
});
|
});
|
||||||
|
|
||||||
return orderBy<HelmRepo>(res.body, repo => repo.name);
|
const repos = res.body.map((repo: any) => {
|
||||||
|
const helmRepo: HelmRepo = {
|
||||||
|
id: repo.repository_id,
|
||||||
|
name: repo.name,
|
||||||
|
url: repo.url,
|
||||||
|
digest: repo.digest,
|
||||||
|
verifiedPublisher: repo.verified_publisher,
|
||||||
|
official: repo.official,
|
||||||
|
lastScanned: repo.last_scanned_ts
|
||||||
|
};
|
||||||
|
|
||||||
|
return helmRepo;
|
||||||
|
});
|
||||||
|
|
||||||
|
return orderBy<HelmRepo>(repos, repo => repo.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async init() {
|
private async init() {
|
||||||
|
|||||||
@ -48,7 +48,7 @@ import { IpcRendererNavigationEvents } from "../renderer/navigation/events";
|
|||||||
import { pushCatalogToRenderer } from "./catalog-pusher";
|
import { pushCatalogToRenderer } from "./catalog-pusher";
|
||||||
import { catalogEntityRegistry } from "./catalog";
|
import { catalogEntityRegistry } from "./catalog";
|
||||||
import { HelmRepoManager } from "./helm/helm-repo-manager";
|
import { HelmRepoManager } from "./helm/helm-repo-manager";
|
||||||
import { syncGeneralEntities, syncWeblinks, KubeconfigSyncManager } from "./catalog-sources";
|
import { syncGeneralEntities, syncWeblinks, KubeconfigSyncManager, syncHelmRepositories } from "./catalog-sources";
|
||||||
import { handleWsUpgrade } from "./proxy/ws-upgrade";
|
import { handleWsUpgrade } from "./proxy/ws-upgrade";
|
||||||
import configurePackages from "../common/configure-packages";
|
import configurePackages from "../common/configure-packages";
|
||||||
import { PrometheusProviderRegistry } from "./prometheus";
|
import { PrometheusProviderRegistry } from "./prometheus";
|
||||||
@ -152,9 +152,6 @@ app.on("ready", async () => {
|
|||||||
ExtensionsStore.createInstance();
|
ExtensionsStore.createInstance();
|
||||||
FilesystemProvisionerStore.createInstance();
|
FilesystemProvisionerStore.createInstance();
|
||||||
WeblinkStore.createInstance();
|
WeblinkStore.createInstance();
|
||||||
|
|
||||||
syncWeblinks();
|
|
||||||
|
|
||||||
HelmRepoManager.createInstance(); // create the instance
|
HelmRepoManager.createInstance(); // create the instance
|
||||||
|
|
||||||
const lensProxy = LensProxy.createInstance(
|
const lensProxy = LensProxy.createInstance(
|
||||||
@ -195,6 +192,9 @@ app.on("ready", async () => {
|
|||||||
ExtensionLoader.createInstance().init();
|
ExtensionLoader.createInstance().init();
|
||||||
extensionDiscovery.init();
|
extensionDiscovery.init();
|
||||||
|
|
||||||
|
syncHelmRepositories();
|
||||||
|
syncWeblinks();
|
||||||
|
|
||||||
// Start the app without showing the main window when auto starting on login
|
// Start the app without showing the main window when auto starting on login
|
||||||
// (On Windows and Linux, we get a flag. On MacOS, we get special API.)
|
// (On Windows and Linux, we get a flag. On MacOS, we get special API.)
|
||||||
const startHidden = process.argv.includes("--hidden") || (isMac && app.getLoginItemSettings().wasOpenedAsHidden);
|
const startHidden = process.argv.includes("--hidden") || (isMac && app.getLoginItemSettings().wasOpenedAsHidden);
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import "../../common/catalog-entities/helm-repository";
|
||||||
import { WebLinkCategory } from "../../common/catalog-entities";
|
import { WebLinkCategory } from "../../common/catalog-entities";
|
||||||
import { WeblinkAddCommand } from "../components/catalog-entities/weblink-add-command";
|
import { WeblinkAddCommand } from "../components/catalog-entities/weblink-add-command";
|
||||||
import { CommandOverlay } from "../components/command-palette";
|
import { CommandOverlay } from "../components/command-palette";
|
||||||
|
|||||||
33
src/renderer/initializers/entity-details-registry.ts
Normal file
33
src/renderer/initializers/entity-details-registry.ts
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { CatalogEntityDetailRegistry } from "../../extensions/registries";
|
||||||
|
import { ConnectionDetails } from "../components/cluster-details/connection-details";
|
||||||
|
|
||||||
|
export function initEntityDetailsRegistry() {
|
||||||
|
CatalogEntityDetailRegistry.getInstance().add({
|
||||||
|
kind: "KubernetesCluster",
|
||||||
|
apiVersions: ["entity.k8slens.dev/v1alpha1"],
|
||||||
|
components: {
|
||||||
|
Details: ConnectionDetails
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
export * from "./command-registry";
|
export * from "./command-registry";
|
||||||
export * from "./entity-settings-registry";
|
export * from "./entity-settings-registry";
|
||||||
|
export * from "./entity-details-registry";
|
||||||
export * from "./kube-object-detail-registry";
|
export * from "./kube-object-detail-registry";
|
||||||
export * from "./kube-object-menu-registry";
|
export * from "./kube-object-menu-registry";
|
||||||
export * from "./registries";
|
export * from "./registries";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user