mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix allowed resources checks on GKE (#6657)
* Add check for incomplete SelfSubjectRulesReview to fix GKE Signed-off-by: Sebastian Malton <sebastian@malton.name> * Adding namespaced for KubeApiResource Signed-off-by: Sebastian Malton <sebastian@malton.name> * Refactoring of AuthorizationNamespaceReview Signed-off-by: Sebastian Malton <sebastian@malton.name> * Removing dead code Signed-off-by: Sebastian Malton <sebastian@malton.name> * Refactoring ListApiResources Signed-off-by: Sebastian Malton <sebastian@malton.name> * Extract ClusterContext into deps for KubeObjectStore to fix circular import Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix remaining type errors Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix crash in frame by consolidating setup into runnables Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix type errors and remove dead code Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix core resources not showing up Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix namespaces not being shown Signed-off-by: Sebastian Malton <sebastian@malton.name> * Simplify ClusterContext to remove something only NamespaceStore needs Signed-off-by: Sebastian Malton <sebastian@malton.name> * Make sure the public API doesn't change Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix lint Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fixing namespace-select-filter tests Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix other tests requiring overrides Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix kludge in cluster-frame tests Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix remaining test failures Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix integration test due to incorrect casting Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix integration test and kube watches not working at all Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix secret details test Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix lint Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix non-ApplicationBuilder tests by adding overrides Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix crash due to trying to read hostedCluster too soon Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix crash due to timing issues - Make injectable phases more explicit for renderer Signed-off-by: Sebastian Malton <sebastian@malton.name> Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
e36f3d2d70
commit
443081493b
196 files changed
+2379
-2146
No files matched your search
@@ -15,13 +15,12 @@ import { ClusterFrame } from "./cluster-frame";
|
||||
import historyInjectable from "../../navigation/history.injectable";
|
||||
import { computed } from "mobx";
|
||||
import type { Cluster } from "../../../common/cluster/cluster";
|
||||
import createClusterInjectable from "../../create-cluster/create-cluster.injectable";
|
||||
import createClusterInjectable from "../../cluster/create-cluster.injectable";
|
||||
import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.injectable";
|
||||
import directoryForUserDataInjectable from "../../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
|
||||
import storesAndApisCanBeCreatedInjectable from "../../stores-apis-can-be-created.injectable";
|
||||
import legacyOnChannelListenInjectable from "../../ipc/legacy-channel-listen.injectable";
|
||||
import currentRouteComponentInjectable from "../../routes/current-route-component.injectable";
|
||||
import allowedResourcesInjectable from "../../cluster-frame-context/allowed-resources.injectable";
|
||||
import hostedClusterIdInjectable from "../../cluster-frame-context/hosted-cluster-id.injectable";
|
||||
import hostedClusterInjectable from "../../cluster-frame-context/hosted-cluster.injectable";
|
||||
import { useFakeTime } from "../../../common/test-utils/use-fake-time";
|
||||
@@ -69,7 +68,8 @@ describe("<ClusterFrame />", () => {
|
||||
|
||||
describe("given cluster with list nodes and namespaces permissions", () => {
|
||||
beforeEach(() => {
|
||||
di.override(allowedResourcesInjectable, () => computed(() => new Set(["nodes", "namespaces"])));
|
||||
// TODO: replace with not using private info
|
||||
(cluster as any).allowedResources.replace(["v1/nodes", "v1/namespaces"]);
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@@ -110,7 +110,7 @@ describe("<ClusterFrame />", () => {
|
||||
|
||||
describe("given cluster without list nodes, but with namespaces permissions", () => {
|
||||
beforeEach(() => {
|
||||
di.override(allowedResourcesInjectable, () => computed(() => new Set(["namespaces"])));
|
||||
(cluster as any).allowedResources.replace(["v1/namespaces"]);
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
|
||||
+4
-2
@@ -7,10 +7,11 @@ import { initClusterFrame } from "./init-cluster-frame";
|
||||
import catalogEntityRegistryInjectable from "../../../api/catalog/entity/registry.injectable";
|
||||
import frameRoutingIdInjectable from "./frame-routing-id/frame-routing-id.injectable";
|
||||
import hostedClusterInjectable from "../../../cluster-frame-context/hosted-cluster.injectable";
|
||||
import clusterFrameContextInjectable from "../../../cluster-frame-context/cluster-frame-context.injectable";
|
||||
import assert from "assert";
|
||||
import emitAppEventInjectable from "../../../../common/app-event-bus/emit-event.injectable";
|
||||
import loadExtensionsInjectable from "../../load-extensions.injectable";
|
||||
import loggerInjectable from "../../../../common/logger.injectable";
|
||||
import showErrorNotificationInjectable from "../../../components/notifications/show-error-notification.injectable";
|
||||
|
||||
const initClusterFrameInjectable = getInjectable({
|
||||
id: "init-cluster-frame",
|
||||
@@ -26,7 +27,8 @@ const initClusterFrameInjectable = getInjectable({
|
||||
catalogEntityRegistry: di.inject(catalogEntityRegistryInjectable),
|
||||
frameRoutingId: di.inject(frameRoutingIdInjectable),
|
||||
emitAppEvent: di.inject(emitAppEventInjectable),
|
||||
clusterFrameContext: di.inject(clusterFrameContextInjectable),
|
||||
logger: di.inject(loggerInjectable),
|
||||
showErrorNotification: di.inject(showErrorNotificationInjectable),
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@@ -4,13 +4,11 @@
|
||||
*/
|
||||
import type { Cluster } from "../../../../common/cluster/cluster";
|
||||
import type { CatalogEntityRegistry } from "../../../api/catalog/entity/registry";
|
||||
import logger from "../../../../main/logger";
|
||||
import { Notifications } from "../../../components/notifications";
|
||||
import type { ShowNotification } from "../../../components/notifications";
|
||||
import { when } from "mobx";
|
||||
import type { ClusterFrameContext } from "../../../cluster-frame-context/cluster-frame-context";
|
||||
import { KubeObjectStore } from "../../../../common/k8s-api/kube-object.store";
|
||||
import { requestSetClusterFrameId } from "../../../ipc";
|
||||
import type { EmitAppEvent } from "../../../../common/app-event-bus/emit-event.injectable";
|
||||
import type { Logger } from "../../../../common/logger";
|
||||
|
||||
interface Dependencies {
|
||||
hostedCluster: Cluster;
|
||||
@@ -18,9 +16,8 @@ interface Dependencies {
|
||||
catalogEntityRegistry: CatalogEntityRegistry;
|
||||
frameRoutingId: number;
|
||||
emitAppEvent: EmitAppEvent;
|
||||
|
||||
// TODO: This dependency belongs to KubeObjectStore
|
||||
clusterFrameContext: ClusterFrameContext;
|
||||
logger: Logger;
|
||||
showErrorNotification: ShowNotification;
|
||||
}
|
||||
|
||||
const logPrefix = "[CLUSTER-FRAME]:";
|
||||
@@ -31,7 +28,8 @@ export const initClusterFrame = ({
|
||||
catalogEntityRegistry,
|
||||
frameRoutingId,
|
||||
emitAppEvent,
|
||||
clusterFrameContext,
|
||||
logger,
|
||||
showErrorNotification,
|
||||
}: Dependencies) =>
|
||||
async (unmountRoot: () => void) => {
|
||||
// TODO: Make catalogEntityRegistry already initialized when passed as dependency
|
||||
@@ -55,14 +53,12 @@ export const initClusterFrame = ({
|
||||
{
|
||||
timeout: 15_000,
|
||||
onError: (error) => {
|
||||
console.warn(
|
||||
logger.warn(
|
||||
"[CLUSTER-FRAME]: error from activeEntity when()",
|
||||
error,
|
||||
);
|
||||
|
||||
Notifications.error(
|
||||
"Failed to get KubernetesCluster for this view. Extensions will not be loaded.",
|
||||
);
|
||||
showErrorNotification("Failed to get KubernetesCluster for this view. Extensions will not be loaded.");
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -84,6 +80,4 @@ export const initClusterFrame = ({
|
||||
|
||||
unmountRoot();
|
||||
};
|
||||
// TODO: Make context dependency of KubeObjectStore
|
||||
KubeObjectStore.defaultContext.set(clusterFrameContext);
|
||||
};
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { beforeFrameStartsInjectionToken } from "../../before-frame-starts/tokens";
|
||||
import { beforeFrameStartsSecondInjectionToken } from "../../before-frame-starts/tokens";
|
||||
import injectSystemCAsInjectable from "../../../common/certificate-authorities/inject-system-cas.injectable";
|
||||
|
||||
const setupSystemCaInjectable = getInjectable({
|
||||
@@ -12,7 +12,7 @@ const setupSystemCaInjectable = getInjectable({
|
||||
id: "setup-system-ca",
|
||||
run: di.inject(injectSystemCAsInjectable),
|
||||
}),
|
||||
injectionToken: beforeFrameStartsInjectionToken,
|
||||
injectionToken: beforeFrameStartsSecondInjectionToken,
|
||||
});
|
||||
|
||||
export default setupSystemCaInjectable;
|
||||
Reference in new issue
Block a user