瀏覽代碼

fix serialize restart spec with null string

Signed-off-by: realityone <[email protected]>
realityone 9 年之前
父節點
當前提交
22d91f60be
共有 3 個文件被更改,包括 9 次插入0 次删除
  1. 2 0
      compose/config/types.py
  2. 4 0
      tests/acceptance/cli_test.py
  3. 3 0
      tests/fixtures/restart/docker-compose.yml

+ 2 - 0
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']))

+ 4 - 0
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': {},

+ 3 - 0
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: ""