Class: Kitchen::Terraform::SystemBastionHostResolver
- Inherits:
-
Object
- Object
- Kitchen::Terraform::SystemBastionHostResolver
- Defined in:
- lib/kitchen/terraform/system_bastion_host_resolver.rb
Overview
SystemBastionHostResolver is the class of objects which resolve a bastion host of a system which may be either dynamically obtained from a Terraform output variable or statically defined.
Instance Method Summary collapse
-
#initialize(outputs:) ⇒ Kitchen::Terraform::SystemBastionHostResolver
constructor
#initialize prepares a new instance of the class.
-
#resolve(bastion_host:, bastion_host_output:) {|bastion_host| ... } ⇒ self
#resolve resolves a bastion host from either the specified Terraform output or the static value.
Constructor Details
#initialize(outputs:) ⇒ Kitchen::Terraform::SystemBastionHostResolver
#initialize prepares a new instance of the class.
28 29 30 |
# File 'lib/kitchen/terraform/system_bastion_host_resolver.rb', line 28 def initialize(outputs:) self.outputs = Hash[outputs] end |
Instance Method Details
#resolve(bastion_host:, bastion_host_output:) {|bastion_host| ... } ⇒ self
#resolve resolves a bastion host from either the specified Terraform output or the static value.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/kitchen/terraform/system_bastion_host_resolver.rb', line 39 def resolve(bastion_host:, bastion_host_output:) if !bastion_host.empty? yield bastion_host: bastion_host elsif !bastion_host_output.empty? yield bastion_host: resolved_output(bastion_host_output: bastion_host_output).fetch(:value) end self rescue ::KeyError raise( ::Kitchen::ClientError, "Resolving the system bastion host failed due to the absence of the 'value' key from the " \ "'#{bastion_host_output}' Terraform output of the Kitchen instance state. This error indicates that the " \ "output format of `terraform output -json` is unexpected." ) end |