Class: Kitchen::Terraform::InSpecRunner
- Inherits:
-
Object
- Object
- Kitchen::Terraform::InSpecRunner
- Defined in:
- lib/kitchen/terraform/inspec_runner.rb
Overview
InSpecRunner is the class of objects which act as interfaces to the InSpec gem.
Class Method Summary collapse
-
.logger=(logger) ⇒ Kitchen::Logger
.logger= sets the logger for all InSpec processes.
Instance Method Summary collapse
-
#exec ⇒ self
#exec executes InSpec.
-
#initialize(options:, profile_locations:) ⇒ Kitchen::Terraform::InSpecRunner
constructor
#initialize prepares a new instance of the class.
Constructor Details
#initialize(options:, profile_locations:) ⇒ Kitchen::Terraform::InSpecRunner
#initialize prepares a new instance of the class.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/kitchen/terraform/inspec_runner.rb', line 59 def initialize(options:, profile_locations:) self.host = .fetch :host do "" end ::Inspec::Plugin::V2::Loader.new.tap do |loader| loader.load_all loader.exit_on_load_error end self.runner = ::Inspec::Runner.new .merge logger: ::Inspec::Log.logger profile_locations.each do |profile_location| runner.add_target profile_location end end |
Class Method Details
.logger=(logger) ⇒ Kitchen::Logger
.logger= sets the logger for all InSpec processes.
The logdev of the logger is extended to conform to interface expected by InSpec.
31 32 33 34 35 36 37 |
# File 'lib/kitchen/terraform/inspec_runner.rb', line 31 def logger=(logger) logger.logdev.define_singleton_method :filename do false end ::Inspec::Log.logger = logger end |
Instance Method Details
#exec ⇒ self
#exec executes InSpec.
44 45 46 47 48 49 50 51 52 |
# File 'lib/kitchen/terraform/inspec_runner.rb', line 44 def exec run do |exit_code:| if 0 != exit_code raise ::Kitchen::TransientFailure, "#{action} failed due to a non-zero exit code of #{exit_code}." end end self end |