mirror of
https://github.com/docker/compose.git
synced 2025-07-17 10:44:26 +02:00
Merge pull request #5898 from docker/5884-ipam-config-schema
Clearly define IPAM config schema for validation
This commit is contained in:
commit
3cf58705b7
@ -281,7 +281,8 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"driver": {"type": "string"},
|
"driver": {"type": "string"},
|
||||||
"config": {
|
"config": {
|
||||||
"type": "array"
|
"type": "array",
|
||||||
|
"items": {"$ref": "#/definitions/ipam_config"}
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@ -305,6 +306,24 @@
|
|||||||
"additionalProperties": false
|
"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": {
|
"volume": {
|
||||||
"id": "#/definitions/volume",
|
"id": "#/definitions/volume",
|
||||||
"type": ["object", "null"],
|
"type": ["object", "null"],
|
||||||
|
@ -332,7 +332,8 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"driver": {"type": "string"},
|
"driver": {"type": "string"},
|
||||||
"config": {
|
"config": {
|
||||||
"type": "array"
|
"type": "array",
|
||||||
|
"items": {"$ref": "#/definitions/ipam_config"}
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@ -359,6 +360,24 @@
|
|||||||
"additionalProperties": false
|
"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": {
|
"volume": {
|
||||||
"id": "#/definitions/volume",
|
"id": "#/definitions/volume",
|
||||||
"type": ["object", "null"],
|
"type": ["object", "null"],
|
||||||
|
@ -341,7 +341,8 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"driver": {"type": "string"},
|
"driver": {"type": "string"},
|
||||||
"config": {
|
"config": {
|
||||||
"type": "array"
|
"type": "array",
|
||||||
|
"items": {"$ref": "#/definitions/ipam_config"}
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@ -368,6 +369,24 @@
|
|||||||
"additionalProperties": false
|
"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": {
|
"volume": {
|
||||||
"id": "#/definitions/volume",
|
"id": "#/definitions/volume",
|
||||||
"type": ["object", "null"],
|
"type": ["object", "null"],
|
||||||
|
@ -385,7 +385,8 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"driver": {"type": "string"},
|
"driver": {"type": "string"},
|
||||||
"config": {
|
"config": {
|
||||||
"type": "array"
|
"type": "array",
|
||||||
|
"items": {"$ref": "#/definitions/ipam_config"}
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@ -412,6 +413,24 @@
|
|||||||
"additionalProperties": false
|
"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": {
|
"volume": {
|
||||||
"id": "#/definitions/volume",
|
"id": "#/definitions/volume",
|
||||||
"type": ["object", "null"],
|
"type": ["object", "null"],
|
||||||
|
@ -384,7 +384,8 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"driver": {"type": "string"},
|
"driver": {"type": "string"},
|
||||||
"config": {
|
"config": {
|
||||||
"type": "array"
|
"type": "array",
|
||||||
|
"items": {"$ref": "#/definitions/ipam_config"}
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@ -411,6 +412,24 @@
|
|||||||
"additionalProperties": false
|
"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": {
|
"volume": {
|
||||||
"id": "#/definitions/volume",
|
"id": "#/definitions/volume",
|
||||||
"type": ["object", "null"],
|
"type": ["object", "null"],
|
||||||
|
@ -1322,6 +1322,28 @@ class ConfigTest(unittest.TestCase):
|
|||||||
assert mount.type == 'bind'
|
assert mount.type == 'bind'
|
||||||
assert mount.source == expected_source
|
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):
|
def test_config_valid_service_names(self):
|
||||||
for valid_name in ['_', '-', '.__.', '_what-up.', 'what_.up----', 'whatup']:
|
for valid_name in ['_', '-', '.__.', '_what-up.', 'what_.up----', 'whatup']:
|
||||||
services = config.load(
|
services = config.load(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user