mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
address some review comments
Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
This commit is contained in:
parent
4b51c22610
commit
f3d009d216
@ -11,4 +11,4 @@ export type { PageRegistration, RegisteredPage, PageParams, PageComponentProps,
|
||||
export type { ClusterPageMenuRegistration, ClusterPageMenuComponents } from "../registries/page-menu-registry";
|
||||
export type { ProtocolHandlerRegistration, RouteParams as ProtocolRouteParams, RouteHandler as ProtocolRouteHandler } from "../registries/protocol-handler";
|
||||
export type { CustomCategoryViewProps, CustomCategoryViewComponents, CustomCategoryViewRegistration } from "../../renderer/components/+catalog/custom-views";
|
||||
export type { ShellEnvModifier, ShellEnvClusterData } from "../../main/shell-session/shell-env-modifier/shell-env-modifier-registration";
|
||||
export type { ShellEnvModifier, ShellEnvContext } from "../../main/shell-session/shell-env-modifier/shell-env-modifier-registration";
|
||||
|
||||
@ -11,13 +11,12 @@ import type { IObservableArray } from "mobx";
|
||||
import type { MenuRegistration } from "../main/menu/menu-registration";
|
||||
import type { TrayMenuRegistration } from "../main/tray/tray-menu-registration";
|
||||
import type { ShellEnvModifier } from "../main/shell-session/shell-env-modifier/shell-env-modifier-registration";
|
||||
import { noop } from "../common/utils";
|
||||
|
||||
export class LensMainExtension extends LensExtension {
|
||||
appMenus: MenuRegistration[] = [];
|
||||
trayMenus: TrayMenuRegistration[] = [];
|
||||
|
||||
shellEnvModifier: ShellEnvModifier = noop;
|
||||
shellEnvModifier?: ShellEnvModifier;
|
||||
|
||||
async navigate(pageId?: string, params?: Record<string, any>, frameId?: number) {
|
||||
return WindowManager.getInstance().navigateExtension(this.id, pageId, params, frameId);
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { noop } from "../../../common/utils";
|
||||
|
||||
export interface ShellEnvClusterData {
|
||||
export interface ShellEnvContext {
|
||||
context: string;
|
||||
kubeconfigPath: string;
|
||||
id: string;
|
||||
}
|
||||
|
||||
export type ShellEnvModifier = ((cluster: ShellEnvClusterData, env: Record<string, string | undefined>) => Record<string, string | undefined>) | typeof noop;
|
||||
export type ShellEnvModifier = (cluster: ShellEnvContext, env: Record<string, string | undefined>) => Record<string, string | undefined>;
|
||||
|
||||
@ -13,6 +13,7 @@ interface Dependencies {
|
||||
export const shellEnvModifiers = ({ extensions }: Dependencies) => {
|
||||
return computed(() => (
|
||||
extensions.get()
|
||||
.flatMap((extension) => extension.shellEnvModifier)
|
||||
.map((extension) => extension.shellEnvModifier)
|
||||
.filter(Boolean)
|
||||
));
|
||||
};
|
||||
|
||||
@ -312,7 +312,7 @@ export abstract class ShellSession {
|
||||
}
|
||||
|
||||
protected async getShellEnv() {
|
||||
let env = clearKubeconfigEnvVars(JSON.parse(JSON.stringify(await shellEnv())));
|
||||
const env = clearKubeconfigEnvVars(JSON.parse(JSON.stringify(await shellEnv())));
|
||||
const pathStr = [...this.getPathEntries(), await this.kubectlBinDirP, process.env.PATH].join(path.delimiter);
|
||||
const shell = UserStore.getInstance().resolvedShell;
|
||||
|
||||
@ -361,9 +361,11 @@ export abstract class ShellSession {
|
||||
.filter(Boolean)
|
||||
.join();
|
||||
|
||||
this.shellEnvModifiers.map(modifier => env = { ...env, ...modifier({ context: this.cluster.contextName, kubeconfigPath, id: this.cluster.id }, env) });
|
||||
const ctx = { context: this.cluster.contextName, kubeconfigPath, id: this.cluster.id };
|
||||
|
||||
return env;
|
||||
const modifiedEnv = this.shellEnvModifiers.reduce((env, modifier) => modifier(ctx, env), env);
|
||||
|
||||
return modifiedEnv;
|
||||
}
|
||||
|
||||
protected exit(code = WebSocketCloseEvent.NormalClosure) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user