Add the ability to sync kube config files (#2567)

* Add the ability to sync kube config files

- Will update when the files changes

- add KUBECONFIG_SYNC label

- fix rebase and change to addObservableSource

- move UI to user settings

- support shallow folder watching

- add some unit tests for the diff-er

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* responding to review comments

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* fix tests and add try/catch

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* always sync c&p folder, remove bad rebase

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* fix preferences

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix settings saving and catalog view

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* fix unit tests

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* fix synced clusters not connectable

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* change to non-complete shallow watching

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* fix sizing

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Catch readStream errors

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* don't clear UserStore on non-existant preference field, fix unlinking not removing items from source

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* change label to file

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2021-04-30 16:48:20 +03:00
1 parent f06d330835
commit 998f7aa934
32 files changed
+1215 -236

No files matched your search

@@ -27,7 +27,7 @@ describe("CatalogEntityRegistry", () => {
it ("allows to add an observable source", () => {
const source = observable.array([]);
registry.addSource("test", source);
registry.addObservableSource("test", source);
expect(registry.items.length).toEqual(0);
source.push(entity);
@@ -38,7 +38,7 @@ describe("CatalogEntityRegistry", () => {
it ("added source change triggers reaction", (done) => {
const source = observable.array([]);
registry.addSource("test", source);
registry.addObservableSource("test", source);
reaction(() => registry.items, () => {
done();
});
@@ -51,7 +51,7 @@ describe("CatalogEntityRegistry", () => {
it ("removes source", () => {
const source = observable.array([]);
registry.addSource("test", source);
registry.addObservableSource("test", source);
source.push(entity);
registry.removeSource("test");
+24 -16
View File
@@ -72,55 +72,63 @@ describe("kube helpers", () => {
});
describe("with default validation options", () => {
describe("with valid kubeconfig", () => {
it("does not raise exceptions", () => {
expect(() => { validateKubeConfig(kc, "valid");}).not.toThrow();
it("does not return an error", () => {
expect(validateKubeConfig(kc, "valid")).toBeUndefined();
});
});
describe("with invalid context object", () => {
it("it raises exception", () => {
expect(() => { validateKubeConfig(kc, "invalid");}).toThrow("No valid context object provided in kubeconfig for context 'invalid'");
it("returns an error", () => {
expect(String(validateKubeConfig(kc, "invalid"))).toEqual(
expect.stringContaining("No valid context object provided in kubeconfig for context 'invalid'")
);
});
});
describe("with invalid cluster object", () => {
it("it raises exception", () => {
expect(() => { validateKubeConfig(kc, "invalidCluster");}).toThrow("No valid cluster object provided in kubeconfig for context 'invalidCluster'");
it("returns an error", () => {
expect(String(validateKubeConfig(kc, "invalidCluster"))).toEqual(
expect.stringContaining("No valid cluster object provided in kubeconfig for context 'invalidCluster'")
);
});
});
describe("with invalid user object", () => {
it("it raises exception", () => {
expect(() => { validateKubeConfig(kc, "invalidUser");}).toThrow("No valid user object provided in kubeconfig for context 'invalidUser'");
it("returns an error", () => {
expect(String(validateKubeConfig(kc, "invalidUser"))).toEqual(
expect.stringContaining("No valid user object provided in kubeconfig for context 'invalidUser'")
);
});
});
describe("with invalid exec command", () => {
it("it raises exception", () => {
expect(() => { validateKubeConfig(kc, "invalidExec");}).toThrow("User Exec command \"foo\" not found on host. Please ensure binary is found in PATH or use absolute path to binary in Kubeconfig");
it("returns an error", () => {
expect(String(validateKubeConfig(kc, "invalidExec"))).toEqual(
expect.stringContaining("User Exec command \"foo\" not found on host. Please ensure binary is found in PATH or use absolute path to binary in Kubeconfig")
);
});
});
});
describe("with validateCluster as false", () => {
describe("with invalid cluster object", () => {
it("does not raise exception", () => {
expect(() => { validateKubeConfig(kc, "invalidCluster", { validateCluster: false });}).not.toThrow();
it("does not return an error", () => {
expect(validateKubeConfig(kc, "invalidCluster", { validateCluster: false })).toBeUndefined();
});
});
});
describe("with validateUser as false", () => {
describe("with invalid user object", () => {
it("does not raise exceptions", () => {
expect(() => { validateKubeConfig(kc, "invalidUser", { validateUser: false });}).not.toThrow();
it("does not return an error", () => {
expect(validateKubeConfig(kc, "invalidUser", { validateUser: false })).toBeUndefined();
});
});
});
describe("with validateExec as false", () => {
describe("with invalid exec object", () => {
it("does not raise exceptions", () => {
expect(() => { validateKubeConfig(kc, "invalidExec", { validateExec: false });}).not.toThrow();
it("does not return an error", () => {
expect(validateKubeConfig(kc, "invalidExec", { validateExec: false })).toBeUndefined();
});
});
});
+3 -2
View File
@@ -19,12 +19,13 @@ import { UserStore } from "../user-store";
import { SemVer } from "semver";
import electron from "electron";
import { stdout, stderr } from "process";
import { beforeEachWrapped } from "../../../integration/helpers/utils";
console = new Console(stdout, stderr);
describe("user store tests", () => {
describe("for an empty config", () => {
beforeEach(() => {
beforeEachWrapped(() => {
UserStore.resetInstance();
mockFs({ tmp: { "config.json": "{}", "kube_config": "{}" } });
@@ -90,7 +91,7 @@ describe("user store tests", () => {
});
describe("migrations", () => {
beforeEach(() => {
beforeEachWrapped(() => {
UserStore.resetInstance();
mockFs({
"tmp": {