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();
|
||||
expect(await fse.pathExists(configPath)).toBe(false);
|
||||
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) { }
|
||||
|
||||
async getPath() {
|
||||
if (!this.tempFile && this.tempFile !== undefined) {
|
||||
async getPath(): Promise<string> {
|
||||
if (this.tempFile === undefined) {
|
||||
throw new Error("kubeconfig is already unlinked");
|
||||
}
|
||||
|
||||
if (!this.tempFile) {
|
||||
await this.init();
|
||||
}
|
||||
|
||||
// create proxy kubeconfig if it is removed
|
||||
if (this.tempFile !== undefined && !(await fs.pathExists(this.tempFile))) {
|
||||
// create proxy kubeconfig if it is removed without unlink called
|
||||
if (!(await fs.pathExists(this.tempFile))) {
|
||||
try {
|
||||
this.tempFile = await this.createProxyKubeconfig();
|
||||
} catch (err) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user