mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix kubeconfig-sync issues (#2692)
- Removed `getFreePort` as its use is always a race condition. Change all uses of it to retrive the port after listening - Added `getPortFrom` as a helper function to read a port from a stream - Remove `Cluster.ownerRef` as it is outdated and no longer needed for 5.0 - Remove `Cluster.enabled`, no longer needed because of above - Removed `Cluster.init`, moved its contents into `Cluster.constructor` as nothing in that function is asyncronous. Currently only being run on `main` as a stop gap until `renderer` gets its own version of `Cluster` - Refactored `LensProxy` so as to prevent `pty.node` (a NodeJS extension) being included in `webpack.extension.ts`'s run - Removed the passing around of the proxy port as that can now be accessed from an instance of `LensProxy` - purge ContextHandler's cache on disconnect Co-authored-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
bf96e6ef4c
commit
8fff064e0c
35 files changed
+563
-893
No files matched your search
@@ -5,10 +5,12 @@ import { Cluster } from "../../cluster";
|
||||
import { computeDiff, configToModels } from "../kubeconfig-sync";
|
||||
import mockFs from "mock-fs";
|
||||
import fs from "fs";
|
||||
import { ClusterStore } from "../../../common/cluster-store";
|
||||
|
||||
describe("kubeconfig-sync.source tests", () => {
|
||||
beforeEach(() => {
|
||||
mockFs();
|
||||
ClusterStore.createInstance();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -57,10 +59,9 @@ describe("kubeconfig-sync.source tests", () => {
|
||||
it("should leave an empty source empty if there are no entries", () => {
|
||||
const contents = "";
|
||||
const rootSource = new ObservableMap<string, [Cluster, CatalogEntity]>();
|
||||
const port = 0;
|
||||
const filePath = "/bar";
|
||||
|
||||
computeDiff(contents, rootSource, port, filePath);
|
||||
computeDiff(contents, rootSource, filePath);
|
||||
|
||||
expect(rootSource.size).toBe(0);
|
||||
});
|
||||
@@ -93,12 +94,11 @@ describe("kubeconfig-sync.source tests", () => {
|
||||
currentContext: "foobar"
|
||||
});
|
||||
const rootSource = new ObservableMap<string, [Cluster, CatalogEntity]>();
|
||||
const port = 0;
|
||||
const filePath = "/bar";
|
||||
|
||||
fs.writeFileSync(filePath, contents);
|
||||
|
||||
computeDiff(contents, rootSource, port, filePath);
|
||||
computeDiff(contents, rootSource, filePath);
|
||||
|
||||
expect(rootSource.size).toBe(1);
|
||||
|
||||
@@ -137,12 +137,11 @@ describe("kubeconfig-sync.source tests", () => {
|
||||
currentContext: "foobar"
|
||||
});
|
||||
const rootSource = new ObservableMap<string, [Cluster, CatalogEntity]>();
|
||||
const port = 0;
|
||||
const filePath = "/bar";
|
||||
|
||||
fs.writeFileSync(filePath, contents);
|
||||
|
||||
computeDiff(contents, rootSource, port, filePath);
|
||||
computeDiff(contents, rootSource, filePath);
|
||||
|
||||
expect(rootSource.size).toBe(1);
|
||||
|
||||
@@ -151,7 +150,7 @@ describe("kubeconfig-sync.source tests", () => {
|
||||
expect(c.kubeConfigPath).toBe("/bar");
|
||||
expect(c.contextName).toBe("context-name");
|
||||
|
||||
computeDiff("{}", rootSource, port, filePath);
|
||||
computeDiff("{}", rootSource, filePath);
|
||||
|
||||
expect(rootSource.size).toBe(0);
|
||||
});
|
||||
@@ -192,12 +191,11 @@ describe("kubeconfig-sync.source tests", () => {
|
||||
currentContext: "foobar"
|
||||
});
|
||||
const rootSource = new ObservableMap<string, [Cluster, CatalogEntity]>();
|
||||
const port = 0;
|
||||
const filePath = "/bar";
|
||||
|
||||
fs.writeFileSync(filePath, contents);
|
||||
|
||||
computeDiff(contents, rootSource, port, filePath);
|
||||
computeDiff(contents, rootSource, filePath);
|
||||
|
||||
expect(rootSource.size).toBe(2);
|
||||
|
||||
@@ -237,7 +235,7 @@ describe("kubeconfig-sync.source tests", () => {
|
||||
currentContext: "foobar"
|
||||
});
|
||||
|
||||
computeDiff(newContents, rootSource, port, filePath);
|
||||
computeDiff(newContents, rootSource, filePath);
|
||||
|
||||
expect(rootSource.size).toBe(1);
|
||||
|
||||
|
||||
Reference in new issue
Block a user