From 22d91f60bea78cbe232a1ac86ba747930ecf7d1a Mon Sep 17 00:00:00 2001 From: realityone Date: Fri, 14 Oct 2016 18:20:55 +0800 Subject: [PATCH] fix serialize restart spec with null string Signed-off-by: realityone --- compose/config/types.py | 2 ++ tests/acceptance/cli_test.py | 4 ++++ tests/fixtures/restart/docker-compose.yml | 3 +++ 3 files changed, 9 insertions(+) diff --git a/compose/config/types.py b/compose/config/types.py index 9664b580..c450a0f9 100644 --- a/compose/config/types.py +++ b/compose/config/types.py @@ -93,6 +93,8 @@ def parse_restart_spec(restart_config): def serialize_restart_spec(restart_spec): + if not restart_spec: + return '' parts = [restart_spec['Name']] if restart_spec['MaximumRetryCount']: parts.append(six.text_type(restart_spec['MaximumRetryCount'])) diff --git a/tests/acceptance/cli_test.py b/tests/acceptance/cli_test.py index 0c7c17bd..e2c02798 100644 --- a/tests/acceptance/cli_test.py +++ b/tests/acceptance/cli_test.py @@ -236,6 +236,10 @@ class CLITestCase(DockerClientTestCase): 'image': 'busybox', 'restart': 'on-failure:5', }, + 'restart-null': { + 'image': 'busybox', + 'restart': '' + }, }, 'networks': {}, 'volumes': {}, diff --git a/tests/fixtures/restart/docker-compose.yml b/tests/fixtures/restart/docker-compose.yml index 2d10aa39..ecfdfbf5 100644 --- a/tests/fixtures/restart/docker-compose.yml +++ b/tests/fixtures/restart/docker-compose.yml @@ -12,3 +12,6 @@ services: on-failure-5: image: busybox restart: "on-failure:5" + restart-null: + image: busybox + restart: ""