mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix shell env cache (#461)
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
8f0c785f58
commit
47082adecd
@ -10,7 +10,7 @@ import { Cluster, ClusterPreferences } from "./cluster"
|
|||||||
import { helmCli } from "./helm-cli"
|
import { helmCli } from "./helm-cli"
|
||||||
|
|
||||||
export class ShellSession extends EventEmitter {
|
export class ShellSession extends EventEmitter {
|
||||||
static shellEnv: any
|
static shellEnvs: Map<string, any> = new Map()
|
||||||
|
|
||||||
protected websocket: WebSocket
|
protected websocket: WebSocket
|
||||||
protected shellProcess: pty.IPty
|
protected shellProcess: pty.IPty
|
||||||
@ -21,6 +21,7 @@ export class ShellSession extends EventEmitter {
|
|||||||
protected helmBinDir: string;
|
protected helmBinDir: string;
|
||||||
protected preferences: ClusterPreferences;
|
protected preferences: ClusterPreferences;
|
||||||
protected running = false;
|
protected running = false;
|
||||||
|
protected clusterId: string;
|
||||||
|
|
||||||
constructor(socket: WebSocket, pathToKubeconfig: string, cluster: Cluster) {
|
constructor(socket: WebSocket, pathToKubeconfig: string, cluster: Cluster) {
|
||||||
super()
|
super()
|
||||||
@ -28,6 +29,7 @@ export class ShellSession extends EventEmitter {
|
|||||||
this.kubeconfigPath = pathToKubeconfig
|
this.kubeconfigPath = pathToKubeconfig
|
||||||
this.kubectl = new Kubectl(cluster.version)
|
this.kubectl = new Kubectl(cluster.version)
|
||||||
this.preferences = cluster.preferences || {}
|
this.preferences = cluster.preferences || {}
|
||||||
|
this.clusterId = cluster.id
|
||||||
}
|
}
|
||||||
|
|
||||||
public async open() {
|
public async open() {
|
||||||
@ -79,16 +81,14 @@ export class ShellSession extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected async getCachedShellEnv() {
|
protected async getCachedShellEnv() {
|
||||||
let env: any
|
let env = ShellSession.shellEnvs.get(this.clusterId)
|
||||||
if (!ShellSession.shellEnv) {
|
if (!env) {
|
||||||
env = await this.getShellEnv()
|
env = await this.getShellEnv()
|
||||||
ShellSession.shellEnv = env
|
ShellSession.shellEnvs.set(this.clusterId, env)
|
||||||
} else {
|
} else {
|
||||||
env = ShellSession.shellEnv
|
|
||||||
|
|
||||||
// refresh env in the background
|
// refresh env in the background
|
||||||
this.getShellEnv().then((shellEnv: any) => {
|
this.getShellEnv().then((shellEnv: any) => {
|
||||||
ShellSession.shellEnv = shellEnv
|
ShellSession.shellEnvs.set(this.clusterId, shellEnv)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user