bernd / fpm-cookery

A tool for building software packages with fpm.
Other
460 stars 88 forks source link

Allow specification of recipe attributes in (templated) YAML file #103

Closed tomeon closed 9 years ago

tomeon commented 9 years ago

This PR is more of an RFC given my weak Ruby-fu. The idea is to allow configuration data like source URL, package name, etc., to be specified in a YAML file (optionally containing embedded Ruby) rather than in the recipe class itself. I find this approach clearer, as it separates data from business logic.

The basic idea is to have a YAML file (by default, config.yml in the same directory as recipe.rb) of the form:

:branch: 'my-branch'
:source: 
    - 'http://svn.mysite.com/<%= branch %>'
    - :with: :svn
:depends:
    - perl
    - pcre-devel
# And so on...

Then, fpm-cookery automatically calls any methods whose names correspond to the top-level keys of the hash created by loading the YAML file. Bonus: the YAML data is processed recursively, so you can use data from the file as template variables for ERB (see the use of branch, above).

Please let me know what you think of this idea. If it looks useful, I can set up some test cases to make sure everything works as expected. Thanks!

beddari commented 9 years ago

Thank you!

This is an idea that I've been thinking about myself and I agree that it is a good way forward. However for an actual implementation I would much rather use the Hiera component of Puppet to achieve this - fpm-cookery already uses Puppet and Facter as helpers.

What do you think, would you be interested in helping me out trying to do this using Hiera?

tomeon commented 9 years ago

Absolutely -- I'd love to help with implementing Hiera! I had actually looked into doing that, but couldn't find much in the way of API documentation for using Hiera in code. Might be time to start digging into the source :).

tomeon commented 9 years ago

Closing pull request; beginning research into Hiera.