Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exposed_ports should accept integers when validating molecule.yml schema #1781

Closed
zeitounator opened this issue Feb 27, 2019 · 2 comments · Fixed by #1798
Closed

exposed_ports should accept integers when validating molecule.yml schema #1781

zeitounator opened this issue Feb 27, 2019 · 2 comments · Fixed by #1798

Comments

@zeitounator
Copy link
Contributor

zeitounator commented Feb 27, 2019

Issue Type

  • Bug report

Molecule and Ansible details

ansible --version && molecule --version

ansible 2.7.8
  config file = None
  configured module search path = ['/home/olcla/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.7 (default, Oct 22 2018, 11:32:17) [GCC 8.2.0]
molecule, version 2.19.1.dev139

Molecule installation method (one of):

Ansible installation method (one of):

  • pip

Desired Behavior

As: a standard molecule user

Given: this molecule.yml extract

 platforms:                                                                                                                                                                    
   - name: instance                                                                                                                                                            
     image: centos:7                                                                                                                                                           
     exposed_ports:                                                                                                                                                            
         - 9900/tcp                                                                                                                                                            
         - "9901/tcp"                                                                                                                                                          
         - 9902/udp                                                                                                                                                            
         - "9903/udp"                                                                                                                                                          
         - 9904                                                                                                                                                                
         - "9905" 

When: I run molecule lint

Then: The command validates the schema of molecule.yml and exit without errors

Actual Behaviour

user@host$ molecule lint
--> Validating schema /home/user/dev/my_test_role/molecule/default/molecule.yml.
ERROR: Failed to validate.

{'platforms': [{0: [{'exposed_ports': [{4: ['must be of string type']}]}]}]}

exposed_ports should accept a list of integers or strings (integer should automatically be casted to strings).

@zeitounator zeitounator changed the title exposed_ports should accept integers when validating schema exposed_ports should accept integers when validating molecule.yml schema Feb 27, 2019
@decentral1se
Copy link
Contributor

decentral1se commented Feb 27, 2019

OK, I think we can use Cerberus coercion for this. Thanks for the report 👍

@decentral1se
Copy link
Contributor

OK, #1798 is out for this!

decentral1se added a commit to decentral1se/molecule that referenced this issue Mar 3, 2019
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants