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
33
@@ -1193,7 +1188,7 @@ async def container_to_args(compose, cnt, detached=True):
1193
1188
# podman does not add shell to handle command with whitespace
1194
1189
podman_args .extend ([
1195
1190
"--healthcheck-command" ,
1196
- "/bin/sh -c " + cmd_quote ( healthcheck_test ),
1191
+ json . dumps ([ "CMD-SHELL" , healthcheck_test ] ),
1197
1192
])
1198
1193
elif is_list (healthcheck_test ):
1199
1194
healthcheck_test = healthcheck_test .copy ()
@@ -1202,13 +1197,11 @@ async def container_to_args(compose, cnt, detached=True):
1202
1197
if healthcheck_type == "NONE" :
1203
1198
podman_args .append ("--no-healthcheck" )
1204
1199
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 ])
1200
+ podman_args .extend (["--healthcheck-command" , json .dumps (healthcheck_test )])
1207
1201
elif healthcheck_type == "CMD-SHELL" :
1208
1202
if len (healthcheck_test ) != 1 :
1209
1203
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 ])
1204
+ podman_args .extend (["--healthcheck-command" , json .dumps (healthcheck_test )])
1212
1205
else :
1213
1206
raise ValueError (
1214
1207
f"unknown healthcheck test type [{ healthcheck_type } ],\
0 commit comments