mirror of
				https://github.com/docker/compose.git
				synced 2025-11-03 21:25:21 +01:00 
			
		
		
		
	Add config validation for service volumes, fixes #5352
Signed-off-by: Drew Romanyk <drewiswaycool@gmail.com>
This commit is contained in:
		
							parent
							
								
									3ce2f03d70
								
							
						
					
					
						commit
						dba2abd523
					
				@ -245,6 +245,7 @@
 | 
				
			|||||||
              {
 | 
					              {
 | 
				
			||||||
                "type": "object",
 | 
					                "type": "object",
 | 
				
			||||||
                "required": ["type"],
 | 
					                "required": ["type"],
 | 
				
			||||||
 | 
					                "additionalProperties": false,
 | 
				
			||||||
                "properties": {
 | 
					                "properties": {
 | 
				
			||||||
                  "type": {"type": "string"},
 | 
					                  "type": {"type": "string"},
 | 
				
			||||||
                  "source": {"type": "string"},
 | 
					                  "source": {"type": "string"},
 | 
				
			||||||
 | 
				
			|||||||
@ -278,6 +278,7 @@
 | 
				
			|||||||
              {
 | 
					              {
 | 
				
			||||||
                "type": "object",
 | 
					                "type": "object",
 | 
				
			||||||
                "required": ["type"],
 | 
					                "required": ["type"],
 | 
				
			||||||
 | 
					                "additionalProperties": false,
 | 
				
			||||||
                "properties": {
 | 
					                "properties": {
 | 
				
			||||||
                  "type": {"type": "string"},
 | 
					                  "type": {"type": "string"},
 | 
				
			||||||
                  "source": {"type": "string"},
 | 
					                  "source": {"type": "string"},
 | 
				
			||||||
 | 
				
			|||||||
@ -282,6 +282,7 @@
 | 
				
			|||||||
              {
 | 
					              {
 | 
				
			||||||
                "type": "object",
 | 
					                "type": "object",
 | 
				
			||||||
                "required": ["type"],
 | 
					                "required": ["type"],
 | 
				
			||||||
 | 
					                "additionalProperties": false,
 | 
				
			||||||
                "properties": {
 | 
					                "properties": {
 | 
				
			||||||
                  "type": {"type": "string"},
 | 
					                  "type": {"type": "string"},
 | 
				
			||||||
                  "source": {"type": "string"},
 | 
					                  "source": {"type": "string"},
 | 
				
			||||||
 | 
				
			|||||||
@ -282,6 +282,7 @@
 | 
				
			|||||||
              {
 | 
					              {
 | 
				
			||||||
                "type": "object",
 | 
					                "type": "object",
 | 
				
			||||||
                "required": ["type"],
 | 
					                "required": ["type"],
 | 
				
			||||||
 | 
					                "additionalProperties": false,
 | 
				
			||||||
                "properties": {
 | 
					                "properties": {
 | 
				
			||||||
                  "type": {"type": "string"},
 | 
					                  "type": {"type": "string"},
 | 
				
			||||||
                  "source": {"type": "string"},
 | 
					                  "source": {"type": "string"},
 | 
				
			||||||
 | 
				
			|||||||
@ -2631,6 +2631,33 @@ class ConfigTest(unittest.TestCase):
 | 
				
			|||||||
        ]
 | 
					        ]
 | 
				
			||||||
        assert service_sort(service_dicts) == service_sort(expected)
 | 
					        assert service_sort(service_dicts) == service_sort(expected)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_service_volume_invalid_config(self):
 | 
				
			||||||
 | 
					        config_details = build_config_details(
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                'version': '3.2',
 | 
				
			||||||
 | 
					                'services': {
 | 
				
			||||||
 | 
					                    'web': {
 | 
				
			||||||
 | 
					                        'build': {
 | 
				
			||||||
 | 
					                            'context': '.',
 | 
				
			||||||
 | 
					                            'args': None,
 | 
				
			||||||
 | 
					                        },
 | 
				
			||||||
 | 
					                        'volumes': [
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                "type": "volume",
 | 
				
			||||||
 | 
					                                "source": "/data",
 | 
				
			||||||
 | 
					                                "garbage": {
 | 
				
			||||||
 | 
					                                    "and": "error"
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        ]
 | 
				
			||||||
 | 
					                    },
 | 
				
			||||||
 | 
					                },
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					        with pytest.raises(ConfigurationError) as exc:
 | 
				
			||||||
 | 
					            config.load(config_details)
 | 
				
			||||||
 | 
					        assert "services.web.volumes contains unsupported option: 'garbage'" in exc.exconly()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class NetworkModeTest(unittest.TestCase):
 | 
					class NetworkModeTest(unittest.TestCase):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user