Class: Kitchen::Pulumi::InSpec

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/pulumi/inspec.rb

Overview

InSpec is the class of objects which act as interfaces to InSpec.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.logger=(logger) ⇒ void

This method returns an undefined value.

.logger= sets the logger for all InSpec processes.

The logdev of the logger is extended to conform to interface expected by InSpec.

Parameters:

  • logger (::Kitchen::Logger)

    the logger to use.


19
20
21
22
23
24
25
# File 'lib/kitchen/pulumi/inspec.rb', line 19

def logger=(logger)
  logger.logdev.define_singleton_method :filename do
    false
  end

  ::Inspec::Log.logger = logger
end

Instance Method Details

#execself

exec executes InSpec.

Returns:

  • (self)

Raises:


32
33
34
35
36
37
38
39
40
41
42
# File 'lib/kitchen/pulumi/inspec.rb', line 32

def exec
  @runner.run.tap do |exit_code|
    if exit_code != 0
      raise ::Kitchen::Pulumi::Error, "InSpec exited with #{exit_code}"
    end
  end

  self
rescue ::ArgumentError, ::RuntimeError, ::Train::UserError => e
  raise ::Kitchen::Pulumi::Error, "Executing InSpec failed\n#{e.message}"
end

#info(message:) ⇒ self

info logs an information message using the InSpec logger.

Parameters:

  • message (::String)

    the message to be logged.

Returns:

  • (self)

48
49
50
51
52
# File 'lib/kitchen/pulumi/inspec.rb', line 48

def info(message:)
  ::Inspec::Log.info ::String.new message

  self
end