Skip to content

Commit

Permalink
Update schema_v2.py
Browse files Browse the repository at this point in the history
Platforms_base_schema destroy copy.deepcopy(base_schema). Then when validating multiply molecules it's running with errors. Eg. two moleule with different drivers. One Azure second docker . If docker will be validated first from it schema we are getting 
 'image': {
                    'type': 'string',
which is not valid for azure driver but will be in schema. 
ERROR: Failed to validate.
{'platforms': [{0: [{'image': ['must be of string type']}], 1: [{'image': ['must be of string type']}], 2: [{'image': ['must be of string type']}]}]}

Moving platforms_base_schema to base_schema and changing the util.merge_dicts fixes the issue.
  • Loading branch information
mickelmayers authored and decentral1se committed Jan 15, 2019
1 parent bf5327b commit 70e3543
Showing 1 changed file with 27 additions and 30 deletions.
57 changes: 27 additions & 30 deletions molecule/model/schema_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,31 @@ def pre_validate_base_schema(env, keep_string):
},
}
},
'platforms': {},
'platforms': {
'type': 'list',
'schema': {
'type': 'dict',
'schema': {
'name': {
'type': 'string',
'required': True,
},
'groups': {
'type': 'list',
'schema': {
'type': 'string',
}
},
'children': {
'type': 'list',
'schema': {
'type': 'string',
}
},
}
}

},
'provisioner': {
'type': 'dict',
'schema': {
Expand Down Expand Up @@ -511,33 +535,6 @@ def pre_validate_base_schema(env, keep_string):
},
}

platforms_base_schema = {
'platforms': {
'type': 'list',
'schema': {
'type': 'dict',
'schema': {
'name': {
'type': 'string',
'required': True,
},
'groups': {
'type': 'list',
'schema': {
'type': 'string',
}
},
'children': {
'type': 'list',
'schema': {
'type': 'string',
}
},
}
}
},
}

platforms_vagrant_schema = {
'platforms': {
'type': 'list',
Expand Down Expand Up @@ -975,7 +972,7 @@ def validate(c):
util.merge_dicts(schema, dependency_command_nullable_schema)

# Driver
util.merge_dicts(schema, platforms_base_schema)
util.merge_dicts(schema, base_schema)
if c['driver']['name'] == 'docker':
util.merge_dicts(schema, platforms_docker_schema)
elif c['driver']['name'] == 'vagrant':
Expand All @@ -986,7 +983,7 @@ def validate(c):
elif c['driver']['name'] == 'linode':
util.merge_dicts(schema, platforms_linode_schema)
else:
util.merge_dicts(schema, platforms_base_schema)
util.merge_dicts(schema, base_schema)

# Verifier
if c['verifier']['name'] == 'goss':
Expand Down

0 comments on commit 70e3543

Please sign in to comment.