Skip to content

Commit ad03a9f

Browse files
authored
Switched from cmd to command (#615)
1 parent ce28d47 commit ad03a9f

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed

lib/schema_checker.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def check_usage_scenario(self, usage_scenario):
102102
Optional("setup-commands"): [str],
103103
Optional("volumes"): self.single_or_list(str),
104104
Optional("folder-destination"):str,
105-
Optional("cmd"): str,
105+
Optional("command"): str,
106106
Optional("log-stdout"): bool,
107107
Optional("log-stderr"): bool,
108108
Optional("read-notes-stdout"): bool,
@@ -130,6 +130,7 @@ def check_usage_scenario(self, usage_scenario):
130130
Optional("compose-file"): Use(self.validate_compose_include)
131131
}, ignore_extra_keys=True)
132132

133+
133134
# This check is necessary to do in a seperate pass. If tried to bake into the schema object above,
134135
# it will not know how to handle the value passed when it could be either a dict or list
135136
if 'networks' in usage_scenario:
@@ -139,6 +140,8 @@ def check_usage_scenario(self, usage_scenario):
139140
service = usage_scenario['services'][service_name]
140141
if 'image' not in service and 'build' not in service:
141142
raise SchemaError("The 'image' key under services is required when 'build' key is not present.")
143+
if 'cmd' in service:
144+
raise SchemaError("The 'cmd' key under services is not supported anymore. Please migrate to 'command'")
142145

143146
usage_scenario_schema.validate(usage_scenario)
144147

runner.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -829,9 +829,6 @@ def setup_services(self):
829829

830830
docker_run_string.append(self.clean_image_name(service['image']))
831831

832-
if 'cmd' in service: # must come last
833-
docker_run_string.append(service['cmd'])
834-
835832
# Before starting the container, check if the dependent containers are "ready".
836833
# If not, wait for some time. If the container is not ready after a certain time, throw an error.
837834
# Currently we consider "ready" only as "running".
@@ -851,15 +848,18 @@ def setup_services(self):
851848
)
852849
state = status_output.strip()
853850
if state == "running":
854-
break;
855-
else:
856-
print(f"State of container '{dependent_container}': {state}. Waiting for 1 second")
857-
self.custom_sleep(1)
858-
time_waited += 1
851+
break
852+
853+
print(f"State of container '{dependent_container}': {state}. Waiting for 1 second")
854+
self.custom_sleep(1)
855+
time_waited += 1
859856

860857
if state != "running":
861858
raise RuntimeError(f"Dependent container '{dependent_container}' of '{container_name}' is not running after waiting for {time_waited} sec! Consider checking your service configuration, the entrypoint of the container or the logs of the container.")
862859

860+
if 'command' in service: # must come last
861+
docker_run_string.append(service['command'])
862+
863863
print(f"Running docker run with: {' '.join(docker_run_string)}")
864864

865865
# docker_run_string must stay as list, cause this forces items to be quoted and escaped and prevents

tests/data/test_cases/subdir_volume_loading/subdir/usage_scenario_subdir.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ services:
1313
volumes:
1414
- ./subdir2/testfile2:/tmp/testfile2-correctly-mounted
1515
- ./subdir2/subdir3/testfile3:/tmp/testfile3-correctly-mounted
16-
cmd: sh
16+
command: sh
1717

1818
flow:
1919
- name: Cat Subdir2

tests/data/usage_scenarios/cmd_stress.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ services:
99
type: container
1010
image: gcb_stress
1111
build: .
12-
cmd: sh
12+
command: sh
1313

1414
flow:
1515
- name: Stress

tests/test_usage_scenario.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ def test_container_is_in_network():
423423
Tests.cleanup(runner)
424424
assert 'test-container' in inspect, Tests.assertion_info('test-container', inspect)
425425

426-
# cmd: [str] (optional)
426+
# command: [str] (optional)
427427
# Command to be executed when container is started.
428428
# When container does not have a daemon running typically a shell
429429
# is started here to have the container running like bash or sh

0 commit comments

Comments
 (0)