Add entrypoint support and quote commands

This commit is contained in:
Fabian 2024-11-07 21:11:32 +01:00
parent 55977c0dc7
commit 602c3a45cf

View File

@ -135,14 +135,18 @@ def write_service_units(args, yaml_dict):
if "command" in service:
enforce_list("command", service)
command = service["command"]
cmd = command[0]
cmd = f'"{command[0]}"'
if len(command) > 1:
cmd += " \\\n"
for i, cmd_part in enumerate(command[1:]):
cmd += f" {cmd_part}"
cmd += f' "{cmd_part}"'
if i < len(command) - 2:
cmd += " \\\n"
unit_file["Container"]["Exec"] = cmd
if "entrypoint" in service:
if not isinstance(service["entrypoint"], str):
abort(f"Only supporting str for entrypoint for now. Got {type(service['entrypoint'])}")
unit_file["Container"]["Entrypoint"] = service["entrypoint"]
if "labels" in service:
enforce_list("labels", service)
unit_file["Container"]["Label"] = service["labels"]