Bladeren bron

Ignore attachable property on networks in compatibility mode

Signed-off-by: Joffrey F <[email protected]>
Joffrey F 7 jaren geleden
bovenliggende
commit
f368b4846f

+ 5 - 4
compose/config/config.py

@@ -918,6 +918,11 @@ def convert_restart_policy(name):
 
 
 def translate_deploy_keys_to_container_config(service_dict):
+    if 'credential_spec' in service_dict:
+        del service_dict['credential_spec']
+    if 'configs' in service_dict:
+        del service_dict['configs']
+
     if 'deploy' not in service_dict:
         return service_dict, []
 
@@ -946,10 +951,6 @@ def translate_deploy_keys_to_container_config(service_dict):
     )
 
     del service_dict['deploy']
-    if 'credential_spec' in service_dict:
-        del service_dict['credential_spec']
-    if 'configs' in service_dict:
-        del service_dict['configs']
 
     return service_dict, ignored_keys
 

+ 4 - 0
compose/config/serialize.py

@@ -80,6 +80,10 @@ def denormalize_config(config, image_digests=None):
                 elif 'external' in conf:
                     conf['external'] = True
 
+            if 'attachable' in conf and config.version < V3_2:
+                # For compatibility mode, this option is invalid in v2
+                del conf['attachable']
+
     return result
 
 

+ 4 - 2
tests/acceptance/cli_test.py

@@ -481,6 +481,7 @@ class CLITestCase(DockerClientTestCase):
         assert yaml.load(result.stdout) == {
             'version': '2.3',
             'volumes': {'foo': {'driver': 'default'}},
+            'networks': {'bar': {}},
             'services': {
                 'foo': {
                     'command': '/bin/true',
@@ -490,9 +491,10 @@ class CLITestCase(DockerClientTestCase):
                     'mem_limit': '300M',
                     'mem_reservation': '100M',
                     'cpus': 0.7,
-                    'volumes': ['foo:/bar:rw']
+                    'volumes': ['foo:/bar:rw'],
+                    'networks': {'bar': None},
                 }
-            }
+            },
         }
 
     def test_ps(self):

+ 6 - 0
tests/fixtures/compatibility-mode/docker-compose.yml

@@ -16,7 +16,13 @@ services:
           memory: 100M
     volumes:
       - foo:/bar
+    networks:
+      - bar
 
 volumes:
   foo:
     driver: default
+
+networks:
+  bar:
+    attachable: true