Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/taskgraph/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ def _index(l: List, s: str) -> Optional[int]:
pass


def load_task(task_id, remove=True):
def load_task(task_id, remove=True, user=None):
user = user or "worker"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just user="worker" in the arguments?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That way the caller can explicitly pass in None and it'll still work. E.g, they can do load_task(..., args.get("user")) or similar.

Just a little habit I picked up

task_def = get_task_definition(task_id)

if (
Expand Down Expand Up @@ -316,7 +317,7 @@ def load_task(task_id, remove=True):
image_tag,
"bash",
"-c",
f"{shlex.join(command)} && cd $TASK_WORKDIR && su -p worker",
f"{shlex.join(command)} && cd $TASK_WORKDIR && su -p {user}",
]

if remove:
Expand Down
3 changes: 2 additions & 1 deletion src/taskgraph/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,11 +667,12 @@ def image_digest(args):
default=True,
help="Keep the docker container after exiting.",
)
@argument("--user", default=None, help="Container user to start shell with.")
def load_task(args):
from taskgraph.docker import load_task

validate_docker()
return load_task(args["task_id"], remove=args["remove"])
return load_task(args["task_id"], remove=args["remove"], user=args["user"])


@command("decision", help="Run the decision task")
Expand Down
Loading