Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Fixes #11214 - support node attribute whitelisting, blacklisting and caching #19

Merged
merged 1 commit into from
Jul 30, 2015

Conversation

balexx
Copy link

@balexx balexx commented Jul 27, 2015

@@ -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)
Copy link
Member

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

@ares ares closed this Jul 28, 2015
@ares ares reopened this Jul 28, 2015

module ChefHandlerForeman
class ForemanFacts < Chef::Handler
attr_accessor :uploader
attr_accessor :blacklist
attr_accessor :whitelist
attr_accessor :cachefile
Copy link
Member

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.

@ares
Copy link
Member

ares commented Jul 30, 2015

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?

@balexx
Copy link
Author

balexx commented Jul 30, 2015

Done!

@ares ares changed the title support node attribute whitelisting, blacklisting and caching Fixes #11214 - support node attribute whitelisting, blacklisting and caching Jul 30, 2015
@ares
Copy link
Member

ares commented Jul 30, 2015

Thank you very much for awesome contribution, I'll release chef-handler-foreman gem 0.0.9 with this feature shortly.

ares added a commit that referenced this pull request Jul 30, 2015
Fixes #11214 - support node attribute whitelisting, blacklisting and caching
@ares ares merged commit 4bd84a4 into theforeman:master Jul 30, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants