Skip to content

Commit 7d8b4dc

Browse files
authored
Merge pull request #269 from crazy-max/docker-return-sock
docker: return docker sock path on install
2 parents 7ed7bac + cae64f3 commit 7d8b4dc

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/docker/install.ts

+13-10
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export class Install {
111111
return tooldir;
112112
}
113113

114-
public async install(): Promise<void> {
114+
public async install(): Promise<string> {
115115
if (!this.toolDir) {
116116
throw new Error('toolDir must be set. Run download first.');
117117
}
@@ -120,24 +120,21 @@ export class Install {
120120
}
121121
switch (os.platform()) {
122122
case 'darwin': {
123-
await this.installDarwin();
124-
break;
123+
return await this.installDarwin();
125124
}
126125
case 'linux': {
127-
await this.installLinux();
128-
break;
126+
return await this.installLinux();
129127
}
130128
case 'win32': {
131-
await this.installWindows();
132-
break;
129+
return await this.installWindows();
133130
}
134131
default: {
135132
throw new Error(`Unsupported platform: ${os.platform()}`);
136133
}
137134
}
138135
}
139136

140-
private async installDarwin(): Promise<void> {
137+
private async installDarwin(): Promise<string> {
141138
const limaDir = path.join(os.homedir(), '.lima', this.limaInstanceName);
142139
await io.mkdirP(limaDir);
143140
const dockerHost = `unix://${limaDir}/docker.sock`;
@@ -225,9 +222,11 @@ export class Install {
225222
await Exec.exec('docker', ['context', 'create', this.contextName, '--docker', `host=${dockerHost}`]);
226223
await Exec.exec('docker', ['context', 'use', this.contextName]);
227224
});
225+
226+
return dockerHost;
228227
}
229228

230-
private async installLinux(): Promise<void> {
229+
private async installLinux(): Promise<string> {
231230
const dockerHost = `unix://${path.join(this.runDir, 'docker.sock')}`;
232231
await io.mkdirP(this.runDir);
233232

@@ -306,9 +305,11 @@ EOF`,
306305
await Exec.exec('docker', ['context', 'create', this.contextName, '--docker', `host=${dockerHost}`]);
307306
await Exec.exec('docker', ['context', 'use', this.contextName]);
308307
});
308+
309+
return dockerHost;
309310
}
310311

311-
private async installWindows(): Promise<void> {
312+
private async installWindows(): Promise<string> {
312313
const dockerHost = 'npipe:////./pipe/setup_docker_action';
313314

314315
let daemonConfig = undefined;
@@ -347,6 +348,8 @@ EOF`,
347348
await Exec.exec('docker', ['context', 'create', this.contextName, '--docker', `host=${dockerHost}`]);
348349
await Exec.exec('docker', ['context', 'use', this.contextName]);
349350
});
351+
352+
return dockerHost;
350353
}
351354

352355
public async tearDown(): Promise<void> {

0 commit comments

Comments
 (0)