Split string commands on whitespace
This change supports specifying commands as strings by spliting the string into a list using python's default whitespace string split(). This will handle simple string commands but not cases like quoted/escaped spaces. Other cases can be handled by specifying the command as a list instead. Change-Id: Icc4eebe324a4e6a7dd06f697ef16d38777f90861
This commit is contained in:
parent
8b7af86908
commit
7ea3e3aec6
@ -81,7 +81,7 @@ def command_argument(cmd, command):
|
|||||||
if not command:
|
if not command:
|
||||||
return []
|
return []
|
||||||
if not isinstance(command, list):
|
if not isinstance(command, list):
|
||||||
return [command]
|
return command.split()
|
||||||
return command
|
return command
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,11 +48,12 @@ class HookDockerCmdTest(common.RunScriptTest):
|
|||||||
"web": {
|
"web": {
|
||||||
"name": "y",
|
"name": "y",
|
||||||
"start_order": 1,
|
"start_order": 1,
|
||||||
"image": "xxx",
|
"image": "yyy",
|
||||||
"net": "host",
|
"net": "host",
|
||||||
"restart": "always",
|
"restart": "always",
|
||||||
"privileged": True,
|
"privileged": True,
|
||||||
"user": "root",
|
"user": "root",
|
||||||
|
"command": "/bin/webserver start",
|
||||||
"volumes": [
|
"volumes": [
|
||||||
"/run:/run",
|
"/run:/run",
|
||||||
"db:/var/lib/db"
|
"db:/var/lib/db"
|
||||||
@ -168,6 +169,7 @@ class HookDockerCmdTest(common.RunScriptTest):
|
|||||||
'--detach=true',
|
'--detach=true',
|
||||||
'--privileged=false',
|
'--privileged=false',
|
||||||
'xxx'
|
'xxx'
|
||||||
|
''
|
||||||
], state[1]['args'])
|
], state[1]['args'])
|
||||||
self.assertEqual([
|
self.assertEqual([
|
||||||
self.fake_tool_path,
|
self.fake_tool_path,
|
||||||
@ -200,7 +202,9 @@ class HookDockerCmdTest(common.RunScriptTest):
|
|||||||
'--user=root',
|
'--user=root',
|
||||||
'--volume=/run:/run',
|
'--volume=/run:/run',
|
||||||
'--volume=db:/var/lib/db',
|
'--volume=db:/var/lib/db',
|
||||||
'xxx'
|
'yyy',
|
||||||
|
'/bin/webserver',
|
||||||
|
'start'
|
||||||
], state[3]['args'])
|
], state[3]['args'])
|
||||||
self.assertEqual([
|
self.assertEqual([
|
||||||
self.fake_tool_path,
|
self.fake_tool_path,
|
||||||
@ -353,7 +357,9 @@ class HookDockerCmdTest(common.RunScriptTest):
|
|||||||
'--user=root',
|
'--user=root',
|
||||||
'--volume=/run:/run',
|
'--volume=/run:/run',
|
||||||
'--volume=db:/var/lib/db',
|
'--volume=db:/var/lib/db',
|
||||||
'xxx'
|
'yyy',
|
||||||
|
'/bin/webserver',
|
||||||
|
'start'
|
||||||
], state[3]['args'])
|
], state[3]['args'])
|
||||||
self.assertEqual([
|
self.assertEqual([
|
||||||
self.fake_tool_path,
|
self.fake_tool_path,
|
||||||
@ -491,7 +497,9 @@ class HookDockerCmdTest(common.RunScriptTest):
|
|||||||
'--user=root',
|
'--user=root',
|
||||||
'--volume=/run:/run',
|
'--volume=/run:/run',
|
||||||
'--volume=db:/var/lib/db',
|
'--volume=db:/var/lib/db',
|
||||||
'xxx'
|
'yyy',
|
||||||
|
'/bin/webserver',
|
||||||
|
'start'
|
||||||
], state[5]['args'])
|
], state[5]['args'])
|
||||||
self.assertEqual([
|
self.assertEqual([
|
||||||
self.fake_tool_path,
|
self.fake_tool_path,
|
||||||
|
Loading…
Reference in New Issue
Block a user