class Kitchen::Pulumi::SystemHostsResolver

SystemHostsResolver is the class of objects which resolve for systems the hosts which are contained in outputs.

Public Class Methods

new(outputs:) click to toggle source

initialize prepares the instance to be used.

@param outputs [#to_hash] the outputs of the Pulumi stack under test.

# File lib/kitchen/pulumi/system_hosts_resolver.rb, line 29
def initialize(outputs:)
  @outputs = outputs.to_h
end

Public Instance Methods

resolve(hosts_output:, system:) click to toggle source

resolve resolves the hosts.

@param hosts_output [::String] the name of the Pulumi output which has

a value of hosts for the system.

@param system [::Kitchen::Pulumi::System] the system. @raise [::Kitchen::Pulumi::Error] if the fetching the value of the

output fails.
# File lib/kitchen/pulumi/system_hosts_resolver.rb, line 18
def resolve(hosts_output:, system:)
  system.add_hosts hosts: @outputs.fetch(hosts_output)
rescue ::KeyError => e
  raise ::Kitchen::Pulumi::Error, "Resolving hosts failed\n#{e}"
end