mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Merge remote-tracking branch 'origin/master' into lens_restructure
# Conflicts: # package.json # src/main/index.ts # src/renderer/api/__test__/parseAPI.test.ts # src/renderer/components/chart/bar-chart.tsx # src/renderer/components/chart/chart.tsx # src/renderer/components/chart/pie-chart.tsx # src/renderer/utils/__tests__/arrays.test.ts # src/renderer/utils/arrays.ts # yarn.lock
This commit is contained in:
commit
f4922811cc
38 files changed
+281
-265
No files matched your search
+6
-5
@@ -29,6 +29,7 @@ if (app.commandLine.getSwitchValue("proxy-server") !== "") {
|
||||
const promiseIpc = new PromiseIpc({ timeout: 2000 })
|
||||
let windowManager: WindowManager = null;
|
||||
let clusterManager: ClusterManager = null;
|
||||
let proxyServer: proxy.LensProxy = null;
|
||||
|
||||
const vmURL = formatUrl({
|
||||
pathname: path.join(__dirname, `${vueAppName}.html`),
|
||||
@@ -64,10 +65,9 @@ async function main() {
|
||||
|
||||
// create cluster manager
|
||||
clusterManager = new ClusterManager(clusterStore.getAllClusterObjects(), port)
|
||||
|
||||
// run proxy
|
||||
try {
|
||||
proxy.listen(port, clusterManager)
|
||||
proxyServer = proxy.listen(port, clusterManager)
|
||||
} catch (error) {
|
||||
logger.error(`Could not start proxy (127.0.0:${port}): ${error.message}`)
|
||||
await dialog.showErrorBox("Lens Error", `Could not start proxy (127.0.0:${port}): ${error.message || "unknown error"}`)
|
||||
@@ -87,7 +87,7 @@ async function main() {
|
||||
},
|
||||
showPreferencesHook: async () => {
|
||||
// IPC send needs webContents as we're sending it to renderer
|
||||
promiseIpc.send('navigate', findMainWebContents(), { name: 'preferences-page' }).then((data: any) => {
|
||||
promiseIpc.send('navigate', findMainWebContents(), {name: 'preferences-page'}).then((data: any) => {
|
||||
logger.debug("navigate: preferences IPC sent");
|
||||
})
|
||||
},
|
||||
@@ -110,10 +110,10 @@ async function main() {
|
||||
}
|
||||
|
||||
app.on("ready", main)
|
||||
app.on('window-all-closed', function () {
|
||||
app.on('window-all-closed', function() {
|
||||
// On OS X it is common for applications and their menu bar
|
||||
// to stay active until the user quits explicitly with Cmd + Q
|
||||
if (!isMac) {
|
||||
if (process.platform != 'darwin') {
|
||||
app.quit();
|
||||
} else {
|
||||
windowManager = null
|
||||
@@ -130,5 +130,6 @@ app.on("activate", () => {
|
||||
app.on("will-quit", async (event) => {
|
||||
event.preventDefault(); // To allow mixpanel sending to be executed
|
||||
if (clusterManager) clusterManager.stop()
|
||||
if (proxyServer) proxyServer.close()
|
||||
app.exit(0);
|
||||
})
|
||||
@@ -18,7 +18,7 @@ export class PrometheusLens implements PrometheusProvider {
|
||||
port: service.spec.ports[0].port
|
||||
}
|
||||
} catch(error) {
|
||||
logger.warn(`PrometheusLens: failed to list services: ${error.toString()}`)
|
||||
logger.warn(`PrometheusLens: failed to list services: ${error.response.body.message}`)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ export class LensProxy {
|
||||
protected clusterManager: ClusterManager
|
||||
protected retryCounters: Map<string, number> = new Map()
|
||||
protected router: Router
|
||||
protected proxyServer: http.Server
|
||||
protected closed = false
|
||||
|
||||
constructor(port: number, clusterManager: ClusterManager) {
|
||||
this.port = port
|
||||
@@ -28,6 +30,13 @@ export class LensProxy {
|
||||
public run() {
|
||||
const proxyServer = this.buildProxyServer();
|
||||
proxyServer.listen(this.port, "127.0.0.1")
|
||||
this.proxyServer = proxyServer
|
||||
}
|
||||
|
||||
public close() {
|
||||
logger.info("Closing proxy server")
|
||||
this.proxyServer.close()
|
||||
this.closed = true
|
||||
}
|
||||
|
||||
protected buildProxyServer() {
|
||||
@@ -68,6 +77,9 @@ export class LensProxy {
|
||||
}
|
||||
})
|
||||
proxy.on("error", (error, req, res, target) => {
|
||||
if(this.closed) {
|
||||
return
|
||||
}
|
||||
if (target) {
|
||||
logger.debug("Failed proxy to target: " + JSON.stringify(target))
|
||||
if (req.method === "GET" && (!res.statusCode || res.statusCode >= 500)) {
|
||||
|
||||
@@ -11,7 +11,7 @@ import { helmCli } from "./helm-cli"
|
||||
import { isWindows } from "../common/vars";
|
||||
|
||||
export class ShellSession extends EventEmitter {
|
||||
static shellEnv: any
|
||||
static shellEnvs: Map<string, any> = new Map()
|
||||
|
||||
protected websocket: WebSocket
|
||||
protected shellProcess: pty.IPty
|
||||
@@ -22,6 +22,7 @@ export class ShellSession extends EventEmitter {
|
||||
protected helmBinDir: string;
|
||||
protected preferences: ClusterPreferences;
|
||||
protected running = false;
|
||||
protected clusterId: string;
|
||||
|
||||
constructor(socket: WebSocket, pathToKubeconfig: string, cluster: Cluster) {
|
||||
super()
|
||||
@@ -29,6 +30,7 @@ export class ShellSession extends EventEmitter {
|
||||
this.kubeconfigPath = pathToKubeconfig
|
||||
this.kubectl = new Kubectl(cluster.version)
|
||||
this.preferences = cluster.preferences || {}
|
||||
this.clusterId = cluster.id
|
||||
}
|
||||
|
||||
public async open() {
|
||||
@@ -77,16 +79,14 @@ export class ShellSession extends EventEmitter {
|
||||
}
|
||||
|
||||
protected async getCachedShellEnv() {
|
||||
let env: any
|
||||
if (!ShellSession.shellEnv) {
|
||||
let env = ShellSession.shellEnvs.get(this.clusterId)
|
||||
if (!env) {
|
||||
env = await this.getShellEnv()
|
||||
ShellSession.shellEnv = env
|
||||
ShellSession.shellEnvs.set(this.clusterId, env)
|
||||
} else {
|
||||
env = ShellSession.shellEnv
|
||||
|
||||
// refresh env in the background
|
||||
this.getShellEnv().then((shellEnv: any) => {
|
||||
ShellSession.shellEnv = shellEnv
|
||||
ShellSession.shellEnvs.set(this.clusterId, shellEnv)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user