28
28
from asyncio import Task
29
29
from enum import Enum
30
30
31
- try :
32
- from shlex import quote as cmd_quote
33
- except ImportError :
34
- from pipes import quote as cmd_quote # pylint: disable=deprecated-module
35
-
36
31
# import fnmatch
37
32
# fnmatch.fnmatchcase(env, "*_HOST")
38
-
39
33
import yaml
40
34
from dotenv import dotenv_values
41
35
@@ -1193,7 +1187,7 @@ async def container_to_args(compose, cnt, detached=True):
1193
1187
# podman does not add shell to handle command with whitespace
1194
1188
podman_args .extend ([
1195
1189
"--healthcheck-command" ,
1196
- "/bin/sh -c " + cmd_quote ( healthcheck_test ),
1190
+ json . dumps ([ "CMD-SHELL" , healthcheck_test ] ),
1197
1191
])
1198
1192
elif is_list (healthcheck_test ):
1199
1193
healthcheck_test = healthcheck_test .copy ()
@@ -1202,13 +1196,11 @@ async def container_to_args(compose, cnt, detached=True):
1202
1196
if healthcheck_type == "NONE" :
1203
1197
podman_args .append ("--no-healthcheck" )
1204
1198
elif healthcheck_type == "CMD" :
1205
- cmd_q = "' '" .join ([cmd_quote (i ) for i in healthcheck_test ])
1206
- podman_args .extend (["--healthcheck-command" , "/bin/sh -c " + cmd_q ])
1199
+ podman_args .extend (["--healthcheck-command" , json .dumps (healthcheck_test )])
1207
1200
elif healthcheck_type == "CMD-SHELL" :
1208
1201
if len (healthcheck_test ) != 1 :
1209
1202
raise ValueError ("'CMD_SHELL' takes a single string after it" )
1210
- cmd_q = cmd_quote (healthcheck_test [0 ])
1211
- podman_args .extend (["--healthcheck-command" , "/bin/sh -c " + cmd_q ])
1203
+ podman_args .extend (["--healthcheck-command" , json .dumps (healthcheck_test )])
1212
1204
else :
1213
1205
raise ValueError (
1214
1206
f"unknown healthcheck test type [{ healthcheck_type } ],\
0 commit comments