From 4becf7719c792ee3949fa9f6ec7e0b6d85011e9d Mon Sep 17 00:00:00 2001 From: Claire McQuin Date: Tue, 4 Nov 2014 09:59:54 -0800 Subject: tie things together --- lib/chef/audit.rb | 1 + lib/chef/audit/chef_json_formatter.rb | 2 +- lib/chef/client.rb | 4 +++- lib/chef/dsl/audit.rb | 5 +---- lib/chef/run_context.rb | 3 +++ 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/chef/audit.rb b/lib/chef/audit.rb index 1e3668396f..43d5c11ee8 100644 --- a/lib/chef/audit.rb +++ b/lib/chef/audit.rb @@ -20,3 +20,4 @@ require 'rspec/core' require 'chef/dsl/audit' require 'chef/audit/chef_json_formatter' +require 'chef/audit/runner' diff --git a/lib/chef/audit/chef_json_formatter.rb b/lib/chef/audit/chef_json_formatter.rb index 3c164120b4..5dcbdb50b7 100644 --- a/lib/chef/audit/chef_json_formatter.rb +++ b/lib/chef/audit/chef_json_formatter.rb @@ -1,5 +1,5 @@ RSpec::Support.require_rspec_core "formatters/base_formatter" -require 'control_group_data' +require 'chef/audit/control_group_data' require 'ffi_yajl' class Chef diff --git a/lib/chef/client.rb b/lib/chef/client.rb index 6c83639ec3..3818f9fad6 100644 --- a/lib/chef/client.rb +++ b/lib/chef/client.rb @@ -25,6 +25,7 @@ require 'chef/log' require 'chef/rest' require 'chef/api_client' require 'chef/api_client/registration' +require 'chef/audit' require 'chef/node' require 'chef/role' require 'chef/file_cache' @@ -344,7 +345,8 @@ class Chef audit_exception = nil begin @events.audit_start(run_context) - # TODO + auditor = Chef::Audit::Runner.new(run_context) + auditor.run @events.audit_complete rescue Exception => e @events.audit_failed(e) diff --git a/lib/chef/dsl/audit.rb b/lib/chef/dsl/audit.rb index 7adcecbf14..948db72921 100644 --- a/lib/chef/dsl/audit.rb +++ b/lib/chef/dsl/audit.rb @@ -27,12 +27,9 @@ class Chef raise ::Chef::Exceptions::NoAuditsProvided unless group_block # TODO add the @example_groups list to the runner for later execution - # run_context.audit_runner.register - ::Chef::Audit::ChefExampleGroup.describe(group_name, &group_block) + run_context.controls_groups << ::Chef::Audit::ChefExampleGroup.describe(group_name, &group_block) end end end end - - diff --git a/lib/chef/run_context.rb b/lib/chef/run_context.rb index 18d353ac61..bdf1cf3d3a 100644 --- a/lib/chef/run_context.rb +++ b/lib/chef/run_context.rb @@ -51,6 +51,8 @@ class Chef # recipes, which is triggered by #load. (See also: CookbookCompiler) attr_accessor :resource_collection + attr_accessor :controls_groups + # Chef::ProviderResolver for this run attr_accessor :provider_resolver @@ -77,6 +79,7 @@ class Chef @node = node @cookbook_collection = cookbook_collection @resource_collection = Chef::ResourceCollection.new + @controls_groups = [] @immediate_notification_collection = Hash.new {|h,k| h[k] = []} @delayed_notification_collection = Hash.new {|h,k| h[k] = []} @definitions = Hash.new -- cgit v1.2.1