mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Restructure to monorepo (#6907)
* wip: restructure to monorepo Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * refactor create-release-pr to a package Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * build fixes Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * github workflow fixes Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix typo Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * add webpack-env types to core Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix github workflows Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * refactor/fix integration tests Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * lint fix Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * yarn run dev Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * eslint settings for vscode Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * move templates to right package Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * open-lens build fixes Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * integration test fix Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix nx task dependencies Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * use bash shell for unit tests in test workflow Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix test:unit for windows Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix win-ca webpack error in open-lens Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix win-ca webpack error in open-lens Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix build:app on windows Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * remove ELECTRON_BUILDER_EXTRA_ARGS Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * sync src/ from master Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * remove Makefile from core Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
1 parent
0066ca4ea2
commit
2657df2293
3321 files changed
+28699
-11447
No files matched your search
+28
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import catalogEntityRegistryInjectable from "../api/catalog/entity/registry.injectable";
|
||||
import { computed } from "mobx";
|
||||
import { isKubernetesCluster } from "../../common/catalog-entities";
|
||||
|
||||
const activeKubernetesClusterInjectable = getInjectable({
|
||||
id: "active-kubernetes-cluster",
|
||||
|
||||
instantiate: (di) => {
|
||||
const catalogEntityRegistry = di.inject(catalogEntityRegistryInjectable);
|
||||
|
||||
return computed(() => {
|
||||
const activeEntity = catalogEntityRegistry.activeEntity;
|
||||
|
||||
if (!isKubernetesCluster(activeEntity)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return activeEntity;
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
export default activeKubernetesClusterInjectable;
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This type is used for KubeObjectStores
|
||||
*/
|
||||
export interface ClusterContext {
|
||||
readonly allNamespaces: string[]; // available / allowed namespaces from cluster.ts
|
||||
readonly contextNamespaces: string[]; // selected by user (see: namespace-select.tsx)
|
||||
readonly hasSelectedAll: boolean;
|
||||
|
||||
isLoadingAll(namespaces: string[]): boolean;
|
||||
isGlobalWatchEnabled(): boolean;
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { ClusterContext } from "./cluster-frame-context";
|
||||
|
||||
const clusterFrameContextForClusterScopedResourcesInjectable = getInjectable({
|
||||
id: "cluster-frame-context-for-cluster-scoped-resources",
|
||||
instantiate: (): ClusterContext => ({
|
||||
// This doesn't matter as it is an optimization for namespaced resources only
|
||||
isGlobalWatchEnabled: () => true,
|
||||
// This is always the case for cluster scoped resources
|
||||
isLoadingAll: () => true,
|
||||
allNamespaces: [],
|
||||
contextNamespaces: [],
|
||||
hasSelectedAll: true,
|
||||
}),
|
||||
});
|
||||
|
||||
export default clusterFrameContextForClusterScopedResourcesInjectable;
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { ClusterContext } from "./cluster-frame-context";
|
||||
import namespaceStoreInjectable from "../components/+namespaces/store.injectable";
|
||||
import hostedClusterInjectable from "./hosted-cluster.injectable";
|
||||
import assert from "assert";
|
||||
import { computed } from "mobx";
|
||||
|
||||
const clusterFrameContextForNamespacedResourcesInjectable = getInjectable({
|
||||
id: "cluster-frame-context-for-namespaced-resources",
|
||||
|
||||
instantiate: (di): ClusterContext => {
|
||||
const cluster = di.inject(hostedClusterInjectable);
|
||||
const namespaceStore = di.inject(namespaceStoreInjectable);
|
||||
|
||||
assert(cluster, "This can only be injected within a cluster frame");
|
||||
|
||||
const allNamespaces = computed(() => {
|
||||
// user given list of namespaces
|
||||
if (cluster.accessibleNamespaces.length) {
|
||||
return cluster.accessibleNamespaces.slice();
|
||||
}
|
||||
|
||||
if (namespaceStore.items.length > 0) {
|
||||
// namespaces from kubernetes api
|
||||
return namespaceStore.items.map((namespace) => namespace.getName());
|
||||
}
|
||||
|
||||
// fallback to cluster resolved namespaces because we could not load list
|
||||
return cluster.allowedNamespaces.slice();
|
||||
});
|
||||
const contextNamespaces = computed(() => namespaceStore.contextNamespaces);
|
||||
const hasSelectedAll = computed(() => {
|
||||
const namespaces = new Set(contextNamespaces.get());
|
||||
|
||||
return allNamespaces.get().length > 1
|
||||
&& cluster.accessibleNamespaces.length === 0
|
||||
&& allNamespaces.get().every(ns => namespaces.has(ns));
|
||||
});
|
||||
|
||||
return {
|
||||
isLoadingAll: (namespaces) => (
|
||||
allNamespaces.get().length > 1
|
||||
&& cluster.accessibleNamespaces.length === 0
|
||||
&& allNamespaces.get().every(ns => namespaces.includes(ns))
|
||||
),
|
||||
isGlobalWatchEnabled: () => cluster.isGlobalWatchEnabled,
|
||||
get allNamespaces() {
|
||||
return allNamespaces.get();
|
||||
},
|
||||
get contextNamespaces() {
|
||||
return contextNamespaces.get();
|
||||
},
|
||||
get hasSelectedAll() {
|
||||
return hasSelectedAll.get();
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
export default clusterFrameContextForNamespacedResourcesInjectable;
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { getClusterIdFromHost } from "../../common/utils";
|
||||
|
||||
const hostedClusterIdInjectable = getInjectable({
|
||||
id: "hosted-cluster-id",
|
||||
instantiate: () => getClusterIdFromHost(location.host),
|
||||
causesSideEffects: true,
|
||||
});
|
||||
|
||||
export default hostedClusterIdInjectable;
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import hostedClusterIdInjectable from "./hosted-cluster-id.injectable";
|
||||
import clusterStoreInjectable from "../../common/cluster-store/cluster-store.injectable";
|
||||
|
||||
const hostedClusterInjectable = getInjectable({
|
||||
id: "hosted-cluster",
|
||||
|
||||
instantiate: (di) => {
|
||||
const hostedClusterId = di.inject(hostedClusterIdInjectable);
|
||||
const store = di.inject(clusterStoreInjectable);
|
||||
|
||||
return store.getById(hostedClusterId);
|
||||
},
|
||||
});
|
||||
|
||||
export default hostedClusterInjectable;
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
|
||||
import { computed } from "mobx";
|
||||
import hostedClusterInjectable from "./hosted-cluster.injectable";
|
||||
import { shouldShowResourceInjectionToken } from "../../common/cluster-store/allowed-resources-injection-token";
|
||||
import type { KubeApiResourceDescriptor } from "../../common/rbac";
|
||||
import { formatKubeApiResource } from "../../common/rbac";
|
||||
|
||||
const shouldShowResourceInjectable = getInjectable({
|
||||
id: "should-show-resource",
|
||||
instantiate: (di, resource) => {
|
||||
const cluster = di.inject(hostedClusterInjectable);
|
||||
|
||||
return cluster
|
||||
? computed(() => cluster.shouldShowResource(resource))
|
||||
: computed(() => false);
|
||||
},
|
||||
injectionToken: shouldShowResourceInjectionToken,
|
||||
lifecycle: lifecycleEnum.keyedSingleton({
|
||||
getInstanceKey: (di, resource: KubeApiResourceDescriptor) => formatKubeApiResource(resource),
|
||||
}),
|
||||
});
|
||||
|
||||
export default shouldShowResourceInjectable;
|
||||
Reference in new issue
Block a user