diff options
author | Marc A. Paradise <marc.paradise@gmail.com> | 2021-06-02 09:49:59 -0400 |
---|---|---|
committer | Marc A. Paradise <marc.paradise@gmail.com> | 2021-06-09 09:20:39 -0400 |
commit | 8e8aa9fa7a7ff5ce802efd855dc0e33f487515e5 (patch) | |
tree | bb53d56e576907a81bbbafffe30e7da582bfff48 | |
parent | 10a4509ac94108403f27d9c3407a20b942defd5e (diff) | |
download | chef-8e8aa9fa7a7ff5ce802efd855dc0e33f487515e5.tar.gz |
Expose Chef::Node#data_for_save as public
This will provide callers (such as event dispatch handlers)
with a means to capture node data that has been filtered based
on attribute whitelist/blacklist rules.
Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
-rw-r--r-- | lib/chef/node.rb | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/lib/chef/node.rb b/lib/chef/node.rb index 6d18baee9c..45e8855326 100644 --- a/lib/chef/node.rb +++ b/lib/chef/node.rb @@ -687,6 +687,25 @@ class Chef name <=> other.name end + # Returns hash of node data with attributes based on whitelist/blacklist rules. + def data_for_save + data = for_json + %w{automatic default normal override}.each do |level| + allowlist = allowlist_or_whitelist_config(level) + unless allowlist.nil? # nil => save everything + logger.info("Allowing #{level} node attributes for save.") + data[level] = Chef::AttributeAllowlist.filter(data[level], allowlist) + end + + blocklist = blocklist_or_blacklist_config(level) + unless blocklist.nil? # nil => remove nothing + logger.info("Blocking #{level} node attributes for save") + data[level] = Chef::AttributeBlocklist.filter(data[level], blocklist) + end + end + data + end + private def save_without_policyfile_attrs @@ -732,24 +751,6 @@ class Chef end end - def data_for_save - data = for_json - %w{automatic default normal override}.each do |level| - allowlist = allowlist_or_whitelist_config(level) - unless allowlist.nil? # nil => save everything - logger.info("Allowing #{level} node attributes for save.") - data[level] = Chef::AttributeAllowlist.filter(data[level], allowlist) - end - - blocklist = blocklist_or_blacklist_config(level) - unless blocklist.nil? # nil => remove nothing - logger.info("Blocking #{level} node attributes for save") - data[level] = Chef::AttributeBlocklist.filter(data[level], blocklist) - end - end - data - end - # Returns a UUID that uniquely identifies this node for reporting reasons. # # The node is read in from disk if it exists, or it's generated if it does |