bernd / fpm-cookery

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

Add fpm_hook recipe directive. #75

Closed unakatsuo closed 10 years ago

unakatsuo commented 10 years ago

This feature allows recipe to change fpm object's attribute directly.

The classes under lib/fpm/cookery/package/* set several fixed fpm attributes. But some attributes are missing accessor method to change the value from the recipe. The fpm_hook exposes the internal object to the recipe and let user to modify it.

Example:

class Recipe < FPM::Cookery::Recipe
  platform :redhat do
    fpm_hook do |fpm|
      fpm.attributes[:rpm_user] = 'httpd'
    end
  end

  platform :debian do
    fpm_hook do |fpm|
      fpm.attributes[:deb_user] = 'apache'
    end
  end
end
beddari commented 10 years ago

I can see why you want this feature however I'm not sure this is the best solution going forward. Reason is that it kind of works against keeping recipies as simple and easy to read as possible.

Would it be better to extend the DSL somehow? Exposing more of the attribs/features you need?

bernd commented 10 years ago

Thanks for suggesting this!

Yes, we need a way to make this kind of control possible. (see #77 and #67) But I would like to avoid adding a DSL method for each and every fpm attribute that exists or will exist in the future.

I would like to propose something between adding DSL methods for each attribute and exposing the complete fpm object.

What do you guys think about having a fpm_attributes DSL method?

class Recipe < FPM::Cookery::Recipe
  platform :redhat do
    fpm_attributes :rpm_user => 'httpd'
  end

  platform :debian do
    fpm_attributes :deb_user => 'apache'
  end
end

We can then document existing fpm attributes including a big CAVEAT that those might change in fpm. (yes, I actually started to create some documentation ;))

This gives users some more control over that kind of settings without having to add everything to the DSL.

thedrow commented 10 years ago

@bernd The syntax looks great. +1.

unakatsuo commented 10 years ago

ok. i'll change the DSL to set the fpm attributes hash specifically.

bernd commented 10 years ago

I merged #80.