class Kitchen::Terraform::CommandExecutor

CommandExecutor is the class of objects which execute Terraform CLI commands.

Attributes

client[RW]
logger[RW]

Public Class Methods

new(client:, logger:) click to toggle source

initialize prepares a new instance of the class.

@param client [String] the pathname of the Terraform client. @param logger [Kitchen::Logger] a logger for logging messages. @return [Kitchen::Terraform::CommandExecutor]

# File lib/kitchen/terraform/command_executor.rb, line 29
def initialize(client:, logger:)
  self.client = client
  self.logger = logger
end

Public Instance Methods

run(command:, options:, &block) click to toggle source

run executes a client command.

@param command [String] the command to run. @param options [Hash] options which adjust the execution of the command. @option options [Integer] :timeout the maximum duration in seconds to run the command. @option options [String] :cwd the directory in which to run the command. @yieldparam standard_output [String] the standard output of the command. @raise [Kitchen::TransientFailure] if running the command results in failure. @return [self]

# File lib/kitchen/terraform/command_executor.rb, line 43
def run(command:, options:, &block)
  ::Kitchen::Terraform::ShellOut.new(
    command: "#{client} #{command}",
    logger: logger,
    options: options,
  ).run(&block)

  self
end