mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
refactor
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
39bc756f11
commit
06893c3fbc
@ -109,6 +109,8 @@ describe("kubeconfig manager tests", () => {
|
|||||||
await kubeConfManager.unlink();
|
await kubeConfManager.unlink();
|
||||||
expect(await fse.pathExists(configPath)).toBe(false);
|
expect(await fse.pathExists(configPath)).toBe(false);
|
||||||
await kubeConfManager.unlink(); // doesn't throw
|
await kubeConfManager.unlink(); // doesn't throw
|
||||||
expect(await kubeConfManager.getPath()).toBeUndefined();
|
expect(async () => {
|
||||||
|
await kubeConfManager.getPath();
|
||||||
|
}).rejects.toThrow("already unlinked");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -13,13 +13,17 @@ export class KubeconfigManager {
|
|||||||
|
|
||||||
constructor(protected cluster: Cluster, protected contextHandler: ContextHandler, protected port: number) { }
|
constructor(protected cluster: Cluster, protected contextHandler: ContextHandler, protected port: number) { }
|
||||||
|
|
||||||
async getPath() {
|
async getPath(): Promise<string> {
|
||||||
if (!this.tempFile && this.tempFile !== undefined) {
|
if (this.tempFile === undefined) {
|
||||||
|
throw new Error("kubeconfig is already unlinked");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.tempFile) {
|
||||||
await this.init();
|
await this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
// create proxy kubeconfig if it is removed
|
// create proxy kubeconfig if it is removed without unlink called
|
||||||
if (this.tempFile !== undefined && !(await fs.pathExists(this.tempFile))) {
|
if (!(await fs.pathExists(this.tempFile))) {
|
||||||
try {
|
try {
|
||||||
this.tempFile = await this.createProxyKubeconfig();
|
this.tempFile = await this.createProxyKubeconfig();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user