mirror of https://github.com/docker/compose.git
Clearly define IPAM config schema for validation
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
7341dba569
commit
398b13d345
|
@ -281,7 +281,8 @@
|
|||
"properties": {
|
||||
"driver": {"type": "string"},
|
||||
"config": {
|
||||
"type": "array"
|
||||
"type": "array",
|
||||
"items": {"$ref": "#/definitions/ipam_config"}
|
||||
},
|
||||
"options": {
|
||||
"type": "object",
|
||||
|
@ -305,6 +306,24 @@
|
|||
"additionalProperties": false
|
||||
},
|
||||
|
||||
"ipam_config": {
|
||||
"id": "#/definitions/ipam_config",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"subnet": {"type": "string"},
|
||||
"iprange": {"type": "string"},
|
||||
"gateway": {"type": "string"},
|
||||
"aux_addresses": {
|
||||
"type": "object",
|
||||
"patternProperties": {
|
||||
"^.+$": {"type": "string"}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
|
||||
"volume": {
|
||||
"id": "#/definitions/volume",
|
||||
"type": ["object", "null"],
|
||||
|
|
|
@ -332,7 +332,8 @@
|
|||
"properties": {
|
||||
"driver": {"type": "string"},
|
||||
"config": {
|
||||
"type": "array"
|
||||
"type": "array",
|
||||
"items": {"$ref": "#/definitions/ipam_config"}
|
||||
},
|
||||
"options": {
|
||||
"type": "object",
|
||||
|
@ -359,6 +360,24 @@
|
|||
"additionalProperties": false
|
||||
},
|
||||
|
||||
"ipam_config": {
|
||||
"id": "#/definitions/ipam_config",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"subnet": {"type": "string"},
|
||||
"iprange": {"type": "string"},
|
||||
"gateway": {"type": "string"},
|
||||
"aux_addresses": {
|
||||
"type": "object",
|
||||
"patternProperties": {
|
||||
"^.+$": {"type": "string"}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
|
||||
"volume": {
|
||||
"id": "#/definitions/volume",
|
||||
"type": ["object", "null"],
|
||||
|
|
|
@ -341,7 +341,8 @@
|
|||
"properties": {
|
||||
"driver": {"type": "string"},
|
||||
"config": {
|
||||
"type": "array"
|
||||
"type": "array",
|
||||
"items": {"$ref": "#/definitions/ipam_config"}
|
||||
},
|
||||
"options": {
|
||||
"type": "object",
|
||||
|
@ -368,6 +369,24 @@
|
|||
"additionalProperties": false
|
||||
},
|
||||
|
||||
"ipam_config": {
|
||||
"id": "#/definitions/ipam_config",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"subnet": {"type": "string"},
|
||||
"iprange": {"type": "string"},
|
||||
"gateway": {"type": "string"},
|
||||
"aux_addresses": {
|
||||
"type": "object",
|
||||
"patternProperties": {
|
||||
"^.+$": {"type": "string"}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
|
||||
"volume": {
|
||||
"id": "#/definitions/volume",
|
||||
"type": ["object", "null"],
|
||||
|
|
|
@ -385,7 +385,8 @@
|
|||
"properties": {
|
||||
"driver": {"type": "string"},
|
||||
"config": {
|
||||
"type": "array"
|
||||
"type": "array",
|
||||
"items": {"$ref": "#/definitions/ipam_config"}
|
||||
},
|
||||
"options": {
|
||||
"type": "object",
|
||||
|
@ -412,6 +413,24 @@
|
|||
"additionalProperties": false
|
||||
},
|
||||
|
||||
"ipam_config": {
|
||||
"id": "#/definitions/ipam_config",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"subnet": {"type": "string"},
|
||||
"iprange": {"type": "string"},
|
||||
"gateway": {"type": "string"},
|
||||
"aux_addresses": {
|
||||
"type": "object",
|
||||
"patternProperties": {
|
||||
"^.+$": {"type": "string"}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
|
||||
"volume": {
|
||||
"id": "#/definitions/volume",
|
||||
"type": ["object", "null"],
|
||||
|
|
|
@ -384,7 +384,8 @@
|
|||
"properties": {
|
||||
"driver": {"type": "string"},
|
||||
"config": {
|
||||
"type": "array"
|
||||
"type": "array",
|
||||
"items": {"$ref": "#/definitions/ipam_config"}
|
||||
},
|
||||
"options": {
|
||||
"type": "object",
|
||||
|
@ -411,6 +412,24 @@
|
|||
"additionalProperties": false
|
||||
},
|
||||
|
||||
"ipam_config": {
|
||||
"id": "#/definitions/ipam_config",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"subnet": {"type": "string"},
|
||||
"iprange": {"type": "string"},
|
||||
"gateway": {"type": "string"},
|
||||
"aux_addresses": {
|
||||
"type": "object",
|
||||
"patternProperties": {
|
||||
"^.+$": {"type": "string"}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
|
||||
"volume": {
|
||||
"id": "#/definitions/volume",
|
||||
"type": ["object", "null"],
|
||||
|
|
|
@ -1322,6 +1322,28 @@ class ConfigTest(unittest.TestCase):
|
|||
assert mount.type == 'bind'
|
||||
assert mount.source == expected_source
|
||||
|
||||
def test_config_invalid_ipam_config(self):
|
||||
with pytest.raises(ConfigurationError) as excinfo:
|
||||
config.load(
|
||||
build_config_details(
|
||||
{
|
||||
'version': str(V2_1),
|
||||
'networks': {
|
||||
'foo': {
|
||||
'driver': 'default',
|
||||
'ipam': {
|
||||
'driver': 'default',
|
||||
'config': ['172.18.0.0/16'],
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
filename='filename.yml',
|
||||
)
|
||||
)
|
||||
assert ('networks.foo.ipam.config contains an invalid type,'
|
||||
' it should be an object') in excinfo.exconly()
|
||||
|
||||
def test_config_valid_service_names(self):
|
||||
for valid_name in ['_', '-', '.__.', '_what-up.', 'what_.up----', 'whatup']:
|
||||
services = config.load(
|
||||
|
|
Loading…
Reference in New Issue