summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/audit/audit_event_proxy.rb2
-rw-r--r--lib/chef/audit/control_group_data.rb7
-rw-r--r--lib/chef/dsl/audit.rb5
3 files changed, 5 insertions, 9 deletions
diff --git a/lib/chef/audit/audit_event_proxy.rb b/lib/chef/audit/audit_event_proxy.rb
index 6d5591d943..36160db9bb 100644
--- a/lib/chef/audit/audit_event_proxy.rb
+++ b/lib/chef/audit/audit_event_proxy.rb
@@ -43,7 +43,7 @@ class Chef
described_class = example.metadata[:described_class]
if described_class
resource_type = described_class.class.name.split(':')[-1]
- # TODO submit github PR to expose this
+ # TODO https://github.com/serverspec/serverspec/pull/493
resource_name = described_class.instance_variable_get(:@name)
end
diff --git a/lib/chef/audit/control_group_data.rb b/lib/chef/audit/control_group_data.rb
index a15127f0c7..42a91ef5a7 100644
--- a/lib/chef/audit/control_group_data.rb
+++ b/lib/chef/audit/control_group_data.rb
@@ -69,11 +69,8 @@ class Chef
:number_failed => number_failed,
:controls => controls.collect { |c| c.to_hash }
}
- h = add_display_only_data(h)
- metadata.each do |k, v|
- h[k] = v
- end
- h
+ # If there is a duplicate key, metadata will overwrite it
+ add_display_only_data(h).merge(metadata)
end
private
diff --git a/lib/chef/dsl/audit.rb b/lib/chef/dsl/audit.rb
index bca9a23c9c..662e1e75c9 100644
--- a/lib/chef/dsl/audit.rb
+++ b/lib/chef/dsl/audit.rb
@@ -22,8 +22,6 @@ class Chef
module DSL
module Audit
- ControlData = Struct.new("ControlData", :args, :block, :metadata)
-
# Can encompass tests in a `control` block or `describe` block
# Adds the controls group and block (containing controls to execute) to the runner's list of pending examples
def controls(*args, &block)
@@ -36,6 +34,7 @@ class Chef
raise Chef::Exceptions::AuditControlGroupDuplicate.new(name)
end
+ # This DSL will only work in the Recipe class because that exposes the cookbook_name
cookbook_name = self.cookbook_name
metadata = {
cookbook_name: cookbook_name,
@@ -44,7 +43,7 @@ class Chef
line_number: block.source_location[1]
}
- run_context.audits[name] = ControlData.new(args, block, metadata)
+ run_context.audits[name] = Struct.new(:args, :block, :metadata).new(args, block, metadata)
end
end