Skip to content

Commit

Permalink
Fix incorrect copying of schema for validation.
Browse files Browse the repository at this point in the history
Full credit to @mickelmayers in #1639.

Originall submitted with message like:

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. Moving
platforms_base_schema to base_schema and changing the util.merge_dicts
fixes the issue.

Closes #1639.

Signed-off-by: Luke Murphy <[email protected]>
  • Loading branch information
mickelmayers authored and decentral1se committed Jan 15, 2019
1 parent bf5327b commit d9401d3
Showing 1 changed file with 26 additions and 30 deletions.
56 changes: 26 additions & 30 deletions molecule/model/schema_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,30 @@ 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 +534,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 +971,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 +982,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 d9401d3

Please sign in to comment.