Allow to extend service using shorthand notation. Closes #1989

Signed-off-by: Karol Duleba <mr.fuxi@gmail.com>
This commit is contained in:
Karol Duleba 2015-09-09 22:30:36 +01:00
commit 91b227d133
4 changed files with 56 additions and 10 deletions

View file

@ -275,15 +275,19 @@ class ServiceLoader(object):
self.service_dict['environment'] = env
def validate_and_construct_extends(self):
extends = self.service_dict['extends']
if not isinstance(extends, dict):
extends = {'service': extends}
validate_extends_file_path(
self.service_name,
self.service_dict['extends'],
extends,
self.filename
)
self.extended_config_path = self.get_extended_config_path(
self.service_dict['extends']
extends
)
self.extended_service_name = self.service_dict['extends']['service']
self.extended_service_name = extends['service']
full_extended_config = pre_process_config(
load_yaml(self.extended_config_path)

View file

@ -57,14 +57,21 @@
},
"extends": {
"type": "object",
"oneOf": [
{
"type": "string"
},
{
"type": "object",
"properties": {
"service": {"type": "string"},
"file": {"type": "string"}
},
"required": ["service"],
"additionalProperties": false
"properties": {
"service": {"type": "string"},
"file": {"type": "string"}
},
"required": ["service"],
"additionalProperties": false
}
]
},
"extra_hosts": {"$ref": "#/definitions/list_or_dict"},