summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc A. Paradise <marc.paradise@gmail.com>2021-06-02 09:49:59 -0400
committerJohn McCrae <john.mccrae@progress.com>2021-06-14 19:01:12 -0700
commit5dc57f6946a3ed211320bfb41e8ea24a018ef483 (patch)
treeebee012060538b0b3135357483dfb2829f2c5131
parentfc43564b1d31bb4258536d05cd47665424d514b6 (diff)
downloadchef-5dc57f6946a3ed211320bfb41e8ea24a018ef483.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.rb37
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