summaryrefslogtreecommitdiff
path: root/lib/chef/dsl/audit.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/dsl/audit.rb')
-rw-r--r--lib/chef/dsl/audit.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/chef/dsl/audit.rb b/lib/chef/dsl/audit.rb
index a11d9039ef..022bbcce01 100644
--- a/lib/chef/dsl/audit.rb
+++ b/lib/chef/dsl/audit.rb
@@ -30,11 +30,20 @@ class Chef
name = args[0]
if name.nil? || name.empty?
raise Chef::Exceptions::AuditNameMissing
- elsif run_context.controls.has_key?(name)
+ elsif run_context.audits.has_key?(name)
raise Chef::Exceptions::AuditControlGroupDuplicate.new(name)
end
- run_context.audits[name] = { :args => args, :block => block }
+ # 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,
+ cookbook_version: self.run_context.cookbook_collection[cookbook_name].version,
+ recipe_name: self.recipe_name,
+ line_number: block.source_location[1]
+ }
+
+ run_context.audits[name] = Struct.new(:args, :block, :metadata).new(args, block, metadata)
end
end