Skip to content

Commit 75590be

Browse files
committed
feat(load-task): add a --user flag to specify which user to run as
1 parent 32c381c commit 75590be

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/taskgraph/docker.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ def _index(l: List, s: str) -> Optional[int]:
251251
pass
252252

253253

254-
def load_task(task_id, remove=True):
254+
def load_task(task_id, remove=True, user=None):
255+
user = user or "worker"
255256
task_def = get_task_definition(task_id)
256257

257258
if (
@@ -316,7 +317,7 @@ def load_task(task_id, remove=True):
316317
image_tag,
317318
"bash",
318319
"-c",
319-
f"{shlex.join(command)} && cd $TASK_WORKDIR && su -p worker",
320+
f"{shlex.join(command)} && cd $TASK_WORKDIR && su -p {user}",
320321
]
321322

322323
if remove:

src/taskgraph/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,11 +667,12 @@ def image_digest(args):
667667
default=True,
668668
help="Keep the docker container after exiting.",
669669
)
670+
@argument("--user", default=None, help="Container user to start shell with.")
670671
def load_task(args):
671672
from taskgraph.docker import load_task
672673

673674
validate_docker()
674-
return load_task(args["task_id"], remove=args["remove"])
675+
return load_task(args["task_id"], remove=args["remove"], user=args["user"])
675676

676677

677678
@command("decision", help="Run the decision task")

0 commit comments

Comments
 (0)