class Kitchen::Pulumi::System
System
is the class of objects which are verified by the Pulumi
Verifier
.
Public Class Methods
new(mapping:)
click to toggle source
# File lib/kitchen/pulumi/system.rb, line 78 def initialize(mapping:) @inputs = {} @hosts = mapping.fetch :hosts do [] end @mapping = mapping end
Public Instance Methods
add_hosts(hosts:)
click to toggle source
add_hosts
adds hosts to the system.
@param hosts [#to_arr,#to_a] the hosts to be added. @return [self]
# File lib/kitchen/pulumi/system.rb, line 27 def add_hosts(hosts:) @hosts += Array hosts self end
add_inputs(inputs:)
click to toggle source
add_inputs
adds Inspec Inputs to the system.
@param inputs [#to_hash] the inputs to be added. @return [self]
# File lib/kitchen/pulumi/system.rb, line 17 def add_inputs(inputs:) @inputs = @inputs.merge Hash inputs self end
each_host() { |host: host| ... }
click to toggle source
each_host
enumerates each host of the system.
@yieldparam host [::String] the next host. @return [self]
# File lib/kitchen/pulumi/system.rb, line 37 def each_host @hosts.each do |host| yield host: host end self end
to_s()
click to toggle source
to_s
returns a string representation of the system.
@return [::String] the name of the system.
# File lib/kitchen/pulumi/system.rb, line 48 def to_s @mapping.fetch :name end
verify(pulumi_inputs:, pulumi_outputs:, inspec_options:)
click to toggle source
verify
verifies the system by executing InSpec
.
@param pulumi_inputs [::Hash] the Pulumi
input values to be utilized as
InSpec profile Input.
@param pulumi_outputs [::Hash] the Pulumi
output values to be utilized as
InSpec profile Input.
@param inspec_options [::Hash] the options to be passed to InSpec
. @return [self]
# File lib/kitchen/pulumi/system.rb, line 60 def verify(pulumi_inputs:, pulumi_outputs:, inspec_options:) resolve(pulumi_inputs: pulumi_inputs, pulumi_outputs: pulumi_outputs) execute_inspec(options: inspec_options) self rescue StandardError => e raise ::Kitchen::Pulumi::Error, "#{self}: #{e.message}" end
Private Instance Methods
execute_inspec(options:)
click to toggle source
# File lib/kitchen/pulumi/system.rb, line 71 def execute_inspec(options:) inspec.new( options: options_with_inputs(options: options), profile_locations: @mapping.fetch(:profile_locations), ).exec(system: self) end
inspec()
click to toggle source
# File lib/kitchen/pulumi/system.rb, line 86 def inspec if @hosts.empty? ::Kitchen::Pulumi::InSpecWithoutHosts else ::Kitchen::Pulumi::InSpecWithHosts end end
options_with_inputs(options:)
click to toggle source
# File lib/kitchen/pulumi/system.rb, line 94 def options_with_inputs(options:) options.merge(inputs: @inputs) end
resolve(pulumi_inputs:, pulumi_outputs:)
click to toggle source
# File lib/kitchen/pulumi/system.rb, line 98 def resolve(pulumi_inputs:, pulumi_outputs:) resolve_inputs(pulumi_inputs: pulumi_inputs, pulumi_outputs: pulumi_outputs) resolve_hosts(pulumi_outputs: pulumi_outputs) end
resolve_hosts(pulumi_outputs:)
click to toggle source
# File lib/kitchen/pulumi/system.rb, line 111 def resolve_hosts(pulumi_outputs:) return self unless @mapping.key?(:hosts_output) ::Kitchen::Pulumi::SystemHostsResolver.new(outputs: pulumi_outputs).resolve( hosts_output: @mapping.fetch(:hosts_output), system: self, ) self end
resolve_inputs(pulumi_inputs:, pulumi_outputs:)
click to toggle source
# File lib/kitchen/pulumi/system.rb, line 103 def resolve_inputs(pulumi_inputs:, pulumi_outputs:) ::Kitchen::Pulumi::SystemInputsResolver.new( pulumi_inputs: pulumi_inputs, pulumi_outputs: pulumi_outputs, system: self, ).resolve self end