diff options
author | Tyler Ball <tyleraball@gmail.com> | 2014-12-08 14:51:20 -0800 |
---|---|---|
committer | Tyler Ball <tyleraball@gmail.com> | 2014-12-08 14:51:20 -0800 |
commit | c6e5654a18f236dd75bb59472e80887c27310d99 (patch) | |
tree | dec361fcc9e502ad4d3d16db048c875725684018 /lib/chef/dsl/audit.rb | |
parent | 9c654e43e87089816dbcaa3b4effe6c47eb8e6be (diff) | |
parent | 07020a416f9f3883b46c7d7aa612426e2c20fa06 (diff) | |
download | chef-c6e5654a18f236dd75bb59472e80887c27310d99.tar.gz |
Merge pull request #2528 from opscode/tball/line-number
Adding cookbook and recipe location information to JSON analytics payload
Diffstat (limited to 'lib/chef/dsl/audit.rb')
-rw-r--r-- | lib/chef/dsl/audit.rb | 13 |
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 |