shell -u argument

This commit is contained in:
Jörn-Michael Miehe 2020-08-24 14:49:17 +02:00
parent 9c198622ca
commit bf0fb911fd

View file

@ -84,13 +84,21 @@ class ShellCommand(ServiceCommand):
help="shell to spawn" help="shell to spawn"
) )
# -u argument: Run as user
self._sub_parser.add_argument(
'-u', '--user', type=str,
help="container user to run shell"
)
def _run_services(self, runner, args, project, services): def _run_services(self, runner, args, project, services):
service = services[0] service = services[0]
shell = _find_shell(args, project, service) shell = _find_shell(args, project, service)
user_args = ['-u', args.user] if args.user else []
if shell is not None: if shell is not None:
# spawn shell # spawn shell
project.compose_run(['exec', service, shell]) project.compose_run(['exec', *user_args, service, shell])
return True return True
return False return False