Class: Kitchen::Terraform::SystemHostsResolver
- Inherits:
-
Object
- Object
- Kitchen::Terraform::SystemHostsResolver
- Defined in:
- lib/kitchen/terraform/system_hosts_resolver.rb
Overview
SystemHostsResolver is the class of objects which resolve the hosts of a system which are contained in Terraform outputs.
Instance Method Summary collapse
-
#initialize(outputs:) ⇒ Kitchen::Terraform::SystemHostsResolver
constructor
#initialize prepares a new instance of the class.
-
#resolve(hosts:, hosts_output:) ⇒ self
#resolve reads the specified Terraform output and stores the value in a list of hosts.
Constructor Details
#initialize(outputs:) ⇒ Kitchen::Terraform::SystemHostsResolver
#initialize prepares a new instance of the class.
28 29 30 |
# File 'lib/kitchen/terraform/system_hosts_resolver.rb', line 28 def initialize(outputs:) self.outputs = Hash[outputs] end |
Instance Method Details
#resolve(hosts:, hosts_output:) ⇒ self
#resolve reads the specified Terraform output and stores the value in a list of hosts.
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/kitchen/terraform/system_hosts_resolver.rb', line 38 def resolve(hosts:, hosts_output:) hosts.concat Array resolved_output(hosts_output: hosts_output).fetch :value self rescue ::KeyError raise( ::Kitchen::ClientError, "Resolving the system hosts failed due to the absence of the 'value' key from the '#{hosts_output}' " \ "Terraform output of the Kitchen instance state. This error indicates that the output format of " \ "`terraform output -json` is unexpected." ) end |