mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
ShellEnv extension api (#4802)
* adding extension api for terminal environment variables Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com> * modified shell env api to work as a transformer (WIP) Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com> * address some review comments Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com> * shell env modifiers now take a CatalogEntity in ShellEnvContext param Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com> * tweaks and bug fix Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com> * refactored to remove ShellEnvModifier code from shell-session to local-shell-session Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com> * further refactoring and documentation Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com> * added comment Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
This commit is contained in:
1 parent
81e6dc5d8e
commit
9b9b8e0d05
7 files changed
+104
-2
No files matched your search
@@ -3,14 +3,22 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type WebSocket from "ws";
|
||||
import path from "path";
|
||||
import { helmCli } from "../../helm/helm-cli";
|
||||
import { UserStore } from "../../../common/user-store";
|
||||
import type { Cluster } from "../../../common/cluster/cluster";
|
||||
import type { ClusterId } from "../../../common/cluster-types";
|
||||
import { ShellSession } from "../shell-session";
|
||||
import type { Kubectl } from "../../kubectl/kubectl";
|
||||
|
||||
export class LocalShellSession extends ShellSession {
|
||||
ShellType = "shell";
|
||||
|
||||
constructor(protected shellEnvModify: (clusterId: ClusterId, env: Record<string, string>) => Record<string, string>, kubectl: Kubectl, websocket: WebSocket, cluster: Cluster, terminalId: string) {
|
||||
super(kubectl, websocket, cluster, terminalId);
|
||||
}
|
||||
|
||||
protected getPathEntries(): string[] {
|
||||
return [helmCli.getBinaryDir()];
|
||||
}
|
||||
@@ -20,7 +28,11 @@ export class LocalShellSession extends ShellSession {
|
||||
}
|
||||
|
||||
public async open() {
|
||||
const env = await this.getCachedShellEnv();
|
||||
let env = await this.getCachedShellEnv();
|
||||
|
||||
// extensions can modify the env
|
||||
env = this.shellEnvModify(this.cluster.id, env);
|
||||
|
||||
const shell = env.PTYSHELL;
|
||||
const args = await this.getShellArgs(shell);
|
||||
|
||||
|
||||
Reference in new issue
Block a user