Skip to content

Commit

Permalink
Coerce exposed_ports to string
Browse files Browse the repository at this point in the history
Closes ansible#1781.

Unfortunately, Cerberus (our schema validation library) is not already
doing this for us. So, we have a bug raised and here is the fix. We're
probably open to numerous version of this bug but let's see when the
reports come in.

Refs:
  * http://docs.python-cerberus.org/en/stable/normalization-rules.html#value-coercion
  * pyeve/cerberus#316

Signed-off-by: Luke Murphy <[email protected]>
  • Loading branch information
decentral1se committed Mar 3, 2019
1 parent cb53404 commit 6400007
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions molecule/model/schema_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
import cerberus
import cerberus.errors

from molecule import interpolation
from molecule import util
from molecule import interpolation, util


def coerce_env(env, keep_string, v):
Expand Down Expand Up @@ -681,6 +680,7 @@ def pre_validate_base_schema(env, keep_string):
'type': 'list',
'schema': {
'type': 'string',
'coerce': str,
}
},
'published_ports': {
Expand Down
7 changes: 7 additions & 0 deletions test/unit/model/v2/test_platforms_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ def test_platforms_docker(_config):
assert {} == schema_v2.validate(_config)


@pytest.mark.parametrize(
'_config', ['_model_platforms_docker_section_data'], indirect=True)
def test_platforms_docker_exposed_ports_coerced(_config):
_config['platforms'][0]['exposed_ports'] = [9904]
assert {} == schema_v2.validate(_config)


@pytest.fixture
def _model_platforms_docker_errors_section_data():
return {
Expand Down

0 comments on commit 6400007

Please sign in to comment.