ajcrowe / puppet-supervisord

Puppet Module to install and configure applications under supervisord
MIT License
37 stars 104 forks source link

Allow integers for numprocs, numprocs_start, retries, ... #36

Closed dol closed 9 years ago

dol commented 9 years ago

I passed an integer for numprocs into supervisord::progame. The validation of validate_re is not able to cast an integer to an string and then perform a regex check. This could be fixed by checking the type with is_integerfirst and then perform a regex check.

ajcrowe commented 9 years ago

Can you detail the code you're using so I can check this.

I thought the re should allow for this already.

dol commented 9 years ago

Not working:

supervisord::program { 'test':
  command  => "/bin/echo",
  numprocs => 1,
}

Working:

supervisord::program { 'test':
  command  => "/bin/echo",
  numprocs => '1',
}
ajcrowe commented 9 years ago

Strange, I define my define types in hiera and don't have this issue. Also when I change the spec tests to use integers it passes fine.

Either way I've fixed the validation so it checks for integers then does the re check so this shouldn't break existing configurations. See 39509c40e38531c54836e7398a568ea5383d78d7 for the details.

If you could test this that would be great!

dol commented 9 years ago

Thank you for the fix. I use loadyaml from puppetlabs/stdlib to dynamically create supervisor program resources. This might be create an integer type internally. I'll test the new version and provide feedback soon.

dol commented 9 years ago

I can confirm that your improvement fixed the issue. Thank you very much.

dol commented 9 years ago

I found the difference that caused the problem. I used the future parser that handles integers and string differently. This comment on the Puppet Mailinglist reminded me of the problem.

It might be a good idea to add the future parser test to travis by adding FUTURE_PARSER=yes as environment variable. This is a feature from the puppetlabs_spec_helper

ajcrowe commented 9 years ago

Yeah, I think this is a good idea.