Class: Kitchen::Pulumi::System

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

Overview

System is the class of objects which are verified by the Pulumi Verifier.

Instance Method Summary collapse

Instance Method Details

#add_attrs(attrs:) ⇒ self

add_attrs adds attributes to the system.

Parameters:

  • attrs (#to_hash)

    the attributes to be added.

Returns:

  • (self)

17
18
19
20
21
# File 'lib/kitchen/pulumi/system.rb', line 17

def add_attrs(attrs:)
  @attributes = @attributes.merge Hash attrs

  self
end

#add_hosts(hosts:) ⇒ self

add_hosts adds hosts to the system.

Parameters:

  • hosts (#to_arr, #to_a)

    the hosts to be added.

Returns:

  • (self)

27
28
29
30
31
# File 'lib/kitchen/pulumi/system.rb', line 27

def add_hosts(hosts:)
  @hosts += Array hosts

  self
end

#each_host {|host| ... } ⇒ self

each_host enumerates each host of the system.

Yield Parameters:

  • host (::String)

    the next host.

Returns:

  • (self)

37
38
39
40
41
42
43
# File 'lib/kitchen/pulumi/system.rb', line 37

def each_host
  @hosts.each do |host|
    yield host: host
  end

  self
end

#to_s::String

to_s returns a string representation of the system.

Returns:

  • (::String)

    the name of the system.


48
49
50
# File 'lib/kitchen/pulumi/system.rb', line 48

def to_s
  @mapping.fetch :name
end

#verify(inputs:, inspec_options:, outputs:) ⇒ self

verify verifies the system by executing InSpec.

Parameters:

  • inputs (::Hash)

    the Pulumi input values to be utilized as InSpec profile attributes.

  • inspec_options (::Hash)

    the options to be passed to InSpec.

  • outputs (::Hash)

    the Pulumi output values to be utilized as InSpec profile attributes.

Returns:

  • (self)

60
61
62
63
64
65
66
67
# File 'lib/kitchen/pulumi/system.rb', line 60

def verify(inputs:, inspec_options:, outputs:)
  resolve inputs: inputs, outputs: outputs
  execute_inspec options: inspec_options

  self
rescue StandardError => e
  raise ::Kitchen::Pulumi::Error, "#{self}: #{e.message}"
end