-
Notifications
You must be signed in to change notification settings - Fork 16
Fixes #11214 - support node attribute whitelisting, blacklisting and caching #19
Conversation
@@ -55,7 +62,15 @@ def normalize(os) | |||
def plain_attributes | |||
# chef 10 attributes can be access by to_hash directly, chef 11 uses attributes method | |||
attributes = node.respond_to?(:attributes) ? node.attributes : node.to_hash | |||
plainify(attributes.to_hash).flatten.inject(&:merge) | |||
if @whitelist | |||
attrs = plainify((attributes.select {|key| @whitelist.include?(key)}).to_hash).flatten.inject(&:merge) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a bit more DRY version
attributes = attributes.select { |key, value| @whitelist.include?(key) } if @whitelist
attrs = plainify((attributes.to_hash).flatten.inject(&:merge)
also note that two arguments in select block (key, value) are required to be compatible with ruby 1.8
|
||
module ChefHandlerForeman | ||
class ForemanFacts < Chef::Handler | ||
attr_accessor :uploader | ||
attr_accessor :blacklist | ||
attr_accessor :whitelist | ||
attr_accessor :cachefile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
last nitpick, could you please rename cachefile
to cache_file
throughout the PR? sounds more like two words to me and it would be more consistent with cache_expired
name.
Tested, works perfectly. Could you please squash all commits into one and change the message to "Fixes #11214 - support node attribute whitelisting, blacklisting and caching" so I can merge it? |
Done! |
Thank you very much for awesome contribution, I'll release chef-handler-foreman gem 0.0.9 with this feature shortly. |
Fixes #11214 - support node attribute whitelisting, blacklisting and caching
As per http://projects.theforeman.org/issues/11214