瀏覽代碼

Merge pull request #2609 from dnephin/dont_warn_on_container_volume

Don't warn when the container volume is a compose option
Daniel Nephin 9 年之前
父節點
當前提交
fc57fc1dc1
共有 2 個文件被更改,包括 13 次插入0 次删除
  1. 1 0
      compose/service.py
  2. 12 0
      tests/unit/service_test.py

+ 1 - 0
compose/service.py

@@ -887,6 +887,7 @@ def warn_on_masked_volume(volumes_option, container_volumes, service):
 
     for volume in volumes_option:
         if (
+            volume.external and
             volume.internal in container_volumes and
             container_volumes.get(volume.internal) != volume.external
         ):

+ 12 - 0
tests/unit/service_test.py

@@ -781,6 +781,18 @@ class ServiceVolumesTest(unittest.TestCase):
 
         assert not mock_log.warn.called
 
+    def test_warn_on_masked_no_warning_with_container_only_option(self):
+        volumes_option = [VolumeSpec(None, '/path', 'rw')]
+        container_volumes = [
+            VolumeSpec('/var/lib/docker/volume/path', '/path', 'rw')
+        ]
+        service = 'service_name'
+
+        with mock.patch('compose.service.log', autospec=True) as mock_log:
+            warn_on_masked_volume(volumes_option, container_volumes, service)
+
+        assert not mock_log.warn.called
+
     def test_create_with_special_volume_mode(self):
         self.mock_client.inspect_image.return_value = {'Id': 'imageid'}