Class: Kitchen::Transport::Terraform
- Inherits:
-
Exec
- Object
- Exec
- Kitchen::Transport::Terraform
- Includes:
- Kitchen::Terraform::ConfigAttribute::Client, Kitchen::Terraform::ConfigAttribute::CommandTimeout, Kitchen::Terraform::ConfigAttribute::RootModuleDirectory, Kitchen::Terraform::Configurable
- Defined in:
- lib/kitchen/transport/terraform.rb
Overview
The Terraform transport is responsible for the integration with the Terraform CLI.
Configuration Attributes
The configuration attributes of the transport control the behaviour of the Terraform commands that are run. Within the Test Kitchen configuration file, these attributes must be declared in the transport
mapping along with the plugin name.
transport:
name: terraform
a_configuration_attribute: some value
client
This attribute contains the pathname of the Terraform client to be used by Kitchen-Terraform.
If the value is not an absolute pathname or a relative pathname then Kitchen-Terraform will attempt to find the value in the directories of the ) PATH.
The pathname of any executable file which implements the interfaces of the following Terraform client commands may be specified: apply; destroy; get; init; validate; workspace.
- Type
- Required
-
False
- Default
-
terraform
- Example
-
client: /usr/local/bin/terraform
- Example
-
client: ./bin/terraform
- Example
-
client: terraform
command_timeout
This attribute controls the number of seconds that the plugin will wait for Terraform commands to finish running.
- Type
- Required
-
False
- Default
-
600
- Example
-
command_timeout: 1200
root_module_directory
This attribute contains the path to the directory which contains the root Terraform module to be tested.
- Type
- Required
-
False
- Default
-
The working directory of the Test Kitchen process.
- Example
-
root_module_directory: /path/to/terraform/root/module/directory
Ruby Interface
This class implements the interface of Kitchen::Configurable which requires the following Reek suppressions: :reek:MissingSafeMethod { exclude: [ finalize_config! ] }
Instance Method Summary collapse
-
#connection(state, &block) ⇒ Kitchen::Terraform::Transport::Connection
#connection creates a new Connection, configured by a merging of configuration and state data.
-
#doctor(_state) ⇒ Boolean
doctor checks the system and configuration for common errors.
-
#finalize_config!(instance) ⇒ self
#finalize_config! invokes the super implementation and then initializes the strategies.
-
#initialize(config = {}) ⇒ Kitchen::Transport::Terraform
constructor
#initialize prepares a new instance of the class.
Methods included from Kitchen::Terraform::Configurable
Methods included from Kitchen::Terraform::ConfigAttribute::RootModuleDirectory
#config_root_module_directory_default_value, included, to_sym
Methods included from Kitchen::Terraform::ConfigAttributeCacher
Methods included from Kitchen::Terraform::ConfigAttribute::Client
#config_client_default_value, #doctor_config_client, included, to_sym
Constructor Details
#initialize(config = {}) ⇒ Kitchen::Transport::Terraform
#initialize prepares a new instance of the class.
116 117 118 |
# File 'lib/kitchen/transport/terraform.rb', line 116 def initialize(config = {}) super config end |
Instance Method Details
#connection(state, &block) ⇒ Kitchen::Terraform::Transport::Connection
#connection creates a new Connection, configured by a merging of configuration and state data.
78 79 80 81 82 |
# File 'lib/kitchen/transport/terraform.rb', line 78 def connection(state, &block) = config.to_hash.merge state ::Kitchen::Terraform::Transport::Connection.new , &block end |
#doctor(_state) ⇒ Boolean
doctor checks the system and configuration for common errors.
88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/kitchen/transport/terraform.rb', line 88 def doctor(_state) errors = false methods.each do |method| next if !method.match? /doctor_config_.*/ error = send method errors = errors || error end errors end |
#finalize_config!(instance) ⇒ self
#finalize_config! invokes the super implementation and then initializes the strategies.
106 107 108 109 110 |
# File 'lib/kitchen/transport/terraform.rb', line 106 def finalize_config!(instance) super instance self end |