diff options
author | Claire McQuin <claire@getchef.com> | 2014-05-14 16:02:06 -0700 |
---|---|---|
committer | Claire McQuin <claire@getchef.com> | 2014-05-15 14:04:59 -0700 |
commit | 1323ffb1de47b31b9e1515c8123c1b8545385a22 (patch) | |
tree | e17343bd84cb455380dc945d87bd782c4b9c8cfd /lib/chef/node.rb | |
parent | 4c48ed4a014480cbb34091df3c79600bd3b7378d (diff) | |
download | chef-1323ffb1de47b31b9e1515c8123c1b8545385a22.tar.gz |
Change attribute whitelist filter syntax to match Ohai
Diffstat (limited to 'lib/chef/node.rb')
-rw-r--r-- | lib/chef/node.rb | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/lib/chef/node.rb b/lib/chef/node.rb index 0a3a4f4297..17ec1d0f0a 100644 --- a/lib/chef/node.rb +++ b/lib/chef/node.rb @@ -34,6 +34,7 @@ require 'chef/node/attribute' require 'chef/mash' require 'chef/json_compat' require 'chef/search/query' +require 'chef/whitelist' class Chef class Node @@ -546,29 +547,17 @@ class Chef private def data_for_save - Chef::Log.info("Whitelisting node attributes for save") data = for_json ["automatic", "default", "normal", "override"].each do |level| whitelist_config_option = "#{level}_attribute_whitelist".to_sym whitelist = Chef::Config[whitelist_config_option] - unless whitelist.nil? # nil is default, saves everything - data[level] = apply_whitelist_filter(data[level], whitelist) + unless whitelist.nil? # nil => save everything + Chef::Log.info("Whitelisting #{level} node attributes for save.") + data[level] = Chef::Whitelist.filter(data[level], whitelist) end end data end - def apply_whitelist_filter(data, whitelist) - return nil if data.nil? - - new_data = data.reject { |k, v| !whitelist.keys.include? k } - whitelist.each do |k, v| - if v.kind_of? Hash - new_data[k] = apply_whitelist_filter(new_data[k], v) - end - end - new_data - end - end end |