Class: Kitchen::Terraform::VariablesManager
- Inherits:
-
Object
- Object
- Kitchen::Terraform::VariablesManager
- Defined in:
- lib/kitchen/terraform/variables_manager.rb
Overview
VariablesManager manages Terraform variables in the Kitchen instance state.
Instance Method Summary collapse
-
#initialize ⇒ Kitchen::Terraform::VariablesManager
constructor
#initialize prepares a new instance of the class.
-
#load(variables:, state:) ⇒ self
#load reads the Terraform variables from the Kitchen instance state and writes them to a container.
-
#save(variables:, state:) ⇒ self
#save reads the Terraform variables from a container and writes them to the Kitchen instance state.
Constructor Details
#initialize ⇒ Kitchen::Terraform::VariablesManager
#initialize prepares a new instance of the class.
26 27 28 |
# File 'lib/kitchen/terraform/variables_manager.rb', line 26 def initialize self.state_key = :kitchen_terraform_variables end |
Instance Method Details
#load(variables:, state:) ⇒ self
#load reads the Terraform variables from the Kitchen instance state and writes them to a container.
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/kitchen/terraform/variables_manager.rb', line 35 def load(variables:, state:) variables.replace state.fetch state_key self rescue ::KeyError => error raise( ::Kitchen::ClientError, "Reading the Terraform input variables from the Kitchen instance state failed due to the absence of the " \ "'#{state_key}' key. This error could indicate that the Kitchen-Terraform provisioner plugin was not used " \ "to converge the Kitchen instance." ) end |
#save(variables:, state:) ⇒ self
#save reads the Terraform variables from a container and writes them to the Kitchen instance state.
53 54 55 56 57 |
# File 'lib/kitchen/terraform/variables_manager.rb', line 53 def save(variables:, state:) state.store state_key, variables self end |