Class: Kitchen::Terraform::InSpecFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/terraform/inspec_factory.rb

Overview

InSpecFactory is the class of objects which build InSpec objects.

Instance Method Summary collapse

Constructor Details

#initialize(fail_fast:, hosts:) ⇒ Kitchen::Terraform::InSpecFactory

#initialize prepares a new instance of the class

Parameters:

  • fail_fast (Boolean)

    a toggle for fail fast or fail slow behaviour.

  • hosts (Array<String>)

    a list of hosts to verify with InSpec.



58
59
60
61
# File 'lib/kitchen/terraform/inspec_factory.rb', line 58

def initialize(fail_fast:, hosts:)
  self.fail_fast = fail_fast
  self.hosts = hosts
end

Instance Method Details

#build(options:, profile_locations:) ⇒ Kitchen::Terraform::InSpec::WithoutHosts, ...

#build creates a new instance of an InSpec object.

Parameters:

  • options (Hash)

    a mapping of InSpec options.

  • profile_locations (Array<::String>)

    the locations of the InSpec profiles which contain the controls to be executed.

Returns:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/kitchen/terraform/inspec_factory.rb', line 32

def build(options:, profile_locations:)
  if hosts.empty?
    ::Kitchen::Terraform::InSpec::WithoutHosts.new(
      options: options,
      profile_locations: profile_locations,
    )
  elsif fail_fast
    ::Kitchen::Terraform::InSpec::FailFastWithHosts.new(
      hosts: hosts,
      options: options,
      profile_locations: profile_locations,
    )
  else
    ::Kitchen::Terraform::InSpec::FailSlowWithHosts.new(
      hosts: hosts,
      options: options,
      profile_locations: profile_locations,
    )
  end
end