Skip to content

Commit c396a10

Browse files
authored
allow passing multiple device options to docker (#1655)
1 parent 1a616c7 commit c396a10

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/argv.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,9 @@ export class Argv {
215215
return this.map.get("privileged") ?? false;
216216
}
217217

218-
get device (): string | null {
219-
const device = this.map.get("device");
220-
if (!device) return null;
221-
return device;
218+
get device (): string[] {
219+
const val = this.map.get("device") ?? [];
220+
return typeof val == "string" ? val.split(" ") : val;
222221
}
223222

224223
get ulimit (): string | null {

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ process.on("SIGUSR2", async () => await cleanupJobResources(jobs));
218218
requiresArg: false,
219219
})
220220
.option("device", {
221-
type: "string",
222-
description: "Set docker executor device option",
221+
type: "array",
222+
description: "Add devices to docker executor",
223223
requiresArg: false,
224224
})
225225
.option("ulimit", {

src/job.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -837,8 +837,8 @@ export class Job {
837837
dockerCmd += "--privileged ";
838838
}
839839

840-
if (this.argv.device) {
841-
dockerCmd += `--device=${this.argv.device} `;
840+
for (const device of this.argv.device) {
841+
dockerCmd += `--device ${device} `;
842842
}
843843

844844
if (this.argv.ulimit !== null) {
@@ -1418,8 +1418,8 @@ export class Job {
14181418
dockerCmd += "--privileged ";
14191419
}
14201420

1421-
if (this.argv.device) {
1422-
dockerCmd += `--device=${this.argv.device} `;
1421+
for (const device of this.argv.device) {
1422+
dockerCmd += `--device ${device} `;
14231423
}
14241424

14251425
if (this.argv.ulimit !== null) {

0 commit comments

Comments
 (0)