From cae64f370a6855fcd46b974f1a67b4c9947f9ea0 Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Thu, 29 Feb 2024 15:57:50 +0100 Subject: [PATCH] docker: return docker sock path on install Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- src/docker/install.ts | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/docker/install.ts b/src/docker/install.ts index b6552240..d3243cb2 100644 --- a/src/docker/install.ts +++ b/src/docker/install.ts @@ -111,7 +111,7 @@ export class Install { return tooldir; } - public async install(): Promise { + public async install(): Promise { if (!this.toolDir) { throw new Error('toolDir must be set. Run download first.'); } @@ -120,16 +120,13 @@ export class Install { } switch (os.platform()) { case 'darwin': { - await this.installDarwin(); - break; + return await this.installDarwin(); } case 'linux': { - await this.installLinux(); - break; + return await this.installLinux(); } case 'win32': { - await this.installWindows(); - break; + return await this.installWindows(); } default: { throw new Error(`Unsupported platform: ${os.platform()}`); @@ -137,7 +134,7 @@ export class Install { } } - private async installDarwin(): Promise { + private async installDarwin(): Promise { const limaDir = path.join(os.homedir(), '.lima', this.limaInstanceName); await io.mkdirP(limaDir); const dockerHost = `unix://${limaDir}/docker.sock`; @@ -225,9 +222,11 @@ export class Install { await Exec.exec('docker', ['context', 'create', this.contextName, '--docker', `host=${dockerHost}`]); await Exec.exec('docker', ['context', 'use', this.contextName]); }); + + return dockerHost; } - private async installLinux(): Promise { + private async installLinux(): Promise { const dockerHost = `unix://${path.join(this.runDir, 'docker.sock')}`; await io.mkdirP(this.runDir); @@ -306,9 +305,11 @@ EOF`, await Exec.exec('docker', ['context', 'create', this.contextName, '--docker', `host=${dockerHost}`]); await Exec.exec('docker', ['context', 'use', this.contextName]); }); + + return dockerHost; } - private async installWindows(): Promise { + private async installWindows(): Promise { const dockerHost = 'npipe:////./pipe/setup_docker_action'; let daemonConfig = undefined; @@ -347,6 +348,8 @@ EOF`, await Exec.exec('docker', ['context', 'create', this.contextName, '--docker', `host=${dockerHost}`]); await Exec.exec('docker', ['context', 'use', this.contextName]); }); + + return dockerHost; } public async tearDown(): Promise {