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
@@ -3,14 +3,14 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import clusterFrameContextInjectable from "../cluster-frame-context/cluster-frame-context.injectable";
|
||||
import clusterFrameContextForNamespacedResourcesInjectable from "../cluster-frame-context/for-namespaced-resources.injectable";
|
||||
import { KubeWatchApi } from "./kube-watch-api";
|
||||
|
||||
const kubeWatchApiInjectable = getInjectable({
|
||||
id: "kube-watch-api",
|
||||
|
||||
instantiate: (di) => new KubeWatchApi({
|
||||
clusterFrameContext: di.inject(clusterFrameContextInjectable),
|
||||
clusterContext: di.inject(clusterFrameContextForNamespacedResourcesInjectable),
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ import { comparer, reaction } from "mobx";
|
||||
import type { Disposer } from "../../common/utils";
|
||||
import { disposer, getOrInsert, noop, WrappedAbortController } from "../../common/utils";
|
||||
import { once } from "lodash";
|
||||
import type { ClusterFrameContext } from "../cluster-frame-context/cluster-frame-context";
|
||||
import logger from "../../common/logger";
|
||||
import type { KubeObjectStoreLoadAllParams, KubeObjectStoreSubscribeParams } from "../../common/k8s-api/kube-object.store";
|
||||
import AbortController from "abort-controller";
|
||||
import type { ClusterContext } from "../cluster-frame-context/cluster-frame-context";
|
||||
|
||||
// Kubernetes watch-api client
|
||||
// API: https://developer.mozilla.org/en-US/docs/Web/API/Streams_API/Using_readable_streams
|
||||
@@ -68,7 +68,7 @@ export interface KubeWatchSubscribeStoreOptions {
|
||||
}
|
||||
|
||||
interface Dependencies {
|
||||
clusterFrameContext: ClusterFrameContext;
|
||||
readonly clusterContext: ClusterContext;
|
||||
}
|
||||
|
||||
export interface SubscribableStore {
|
||||
@@ -86,7 +86,7 @@ export type SubscribeStores = (stores: SubscribableStore[], opts?: KubeWatchSubs
|
||||
export class KubeWatchApi {
|
||||
readonly #watch = new WatchCount();
|
||||
|
||||
constructor(private dependencies: Dependencies) {}
|
||||
constructor(private readonly dependencies: Dependencies) {}
|
||||
|
||||
private subscribeStore({ store, parent, namespaces, onLoadFailure }: SubscribeStoreParams): Disposer {
|
||||
const isNamespaceFilterWatch = !namespaces;
|
||||
@@ -96,7 +96,7 @@ export class KubeWatchApi {
|
||||
return () => this.#watch.dec(store);
|
||||
}
|
||||
|
||||
namespaces ??= this.dependencies.clusterFrameContext?.contextNamespaces ?? [];
|
||||
namespaces ??= this.dependencies.clusterContext?.contextNamespaces ?? [];
|
||||
|
||||
let childController = new WrappedAbortController(parent);
|
||||
const unsubscribe = disposer();
|
||||
@@ -123,7 +123,7 @@ export class KubeWatchApi {
|
||||
const cancelReloading = isNamespaceFilterWatch && store.api.isNamespaced
|
||||
? reaction(
|
||||
// Note: must slice because reaction won't fire if it isn't there
|
||||
() => [this.dependencies.clusterFrameContext.contextNamespaces.slice(), this.dependencies.clusterFrameContext.hasSelectedAll] as const,
|
||||
() => [this.dependencies.clusterContext.contextNamespaces.slice(), this.dependencies.clusterContext.hasSelectedAll] as const,
|
||||
([namespaces, curSelectedAll], [prevNamespaces, prevSelectedAll]) => {
|
||||
if (curSelectedAll && prevSelectedAll) {
|
||||
const action = namespaces.length > prevNamespaces.length ? "created" : "deleted";
|
||||
|
||||
@@ -7,7 +7,6 @@ import kubeWatchApiInjectable from "./kube-watch-api.injectable";
|
||||
|
||||
const subscribeStoresInjectable = getInjectable({
|
||||
id: "subscribe-stores",
|
||||
causesSideEffects: true,
|
||||
instantiate: (di) => di.inject(kubeWatchApiInjectable).subscribeStores,
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user