summaryrefslogtreecommitdiff
path: root/lib/chef/policy_builder
diff options
context:
space:
mode:
authorTyler Cloke <tylercloke@gmail.com>2017-06-20 12:23:56 -0700
committerTyler Cloke <tylercloke@gmail.com>2017-06-20 16:42:16 -0700
commit7102108e89e6045323dded023a36f2e3672fd43b (patch)
tree7bdf8d6f4be06898b056149becbbb8678756902c /lib/chef/policy_builder
parent5c4dbb8b34f55e2e253f988cc958c8b0e78ccea5 (diff)
downloadchef-7102108e89e6045323dded023a36f2e3672fd43b.tar.gz
Properly send run_list_expanded event in policy node casetc/fix-expanded-run-list-reporting-for-policyfiles
Signed-off-by: Tyler Cloke <tylercloke@gmail.com>
Diffstat (limited to 'lib/chef/policy_builder')
-rw-r--r--lib/chef/policy_builder/policyfile.rb28
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/chef/policy_builder/policyfile.rb b/lib/chef/policy_builder/policyfile.rb
index f84e1dc68e..545d36cb0e 100644
--- a/lib/chef/policy_builder/policyfile.rb
+++ b/lib/chef/policy_builder/policyfile.rb
@@ -51,7 +51,32 @@ class Chef
class PolicyfileError < StandardError; end
- RunListExpansionIsh = Struct.new(:recipes, :roles)
+ RunListExpansionIsh = Struct.new(:recipes, :roles) do
+ # Implementing the parts of the RunListExpansion
+ # interface we need to properly send this through to
+ # events.run_list_expanded as it is expecting a RunListExpansion
+ # object.
+ def to_hash
+ # It looks like version only gets populated in the expanded_run_list when
+ # using a little used feature of roles to version lock cookbooks, so
+ # version is not reliable in here anyway (places like Automate UI are
+ # not getting version out of here.
+ #
+ # Skipped will always be false as it can only be true when two expanded
+ # roles contain the same recipe.
+ expanded_run_list = recipes.map do |r|
+ { type: "recipe", name: r, skipped: false, version: nil }
+ end
+ data_collector_hash = {}
+ data_collector_hash[:id] = "_policy_node"
+ data_collector_hash[:run_list] = expanded_run_list
+ data_collector_hash
+ end
+
+ def to_json(*opts)
+ to_hash.to_json(*opts)
+ end
+ end
attr_reader :events
attr_reader :node
@@ -137,6 +162,7 @@ class Chef
Chef::Log.info("Run List expands to [#{run_list_with_versions_for_display.join(', ')}]")
events.node_load_completed(node, run_list_with_versions_for_display, Chef::Config)
+ events.run_list_expanded(run_list_expansion_ish)
node
rescue Exception => e