lib/rspec/terraform/helpers/destroy.rb in rspec-terraform-0.1.0.pre.41 vs lib/rspec/terraform/helpers/destroy.rb in rspec-terraform-0.1.0.pre.42

- old
+ new

@@ -5,19 +5,30 @@ require_relative '../configuration/var_captor' module RSpec module Terraform module Helpers + # rubocop:disable Metrics/ClassLength class Destroy attr_reader( - :configuration_provider, :binary, :execution_mode + :configuration_provider, + :binary, + :logger, + :stdin, + :stdout, + :stderr, + :execution_mode ) def initialize(opts = {}) @configuration_provider = opts[:configuration_provider] || Configuration.identity_provider @binary = opts[:binary] || 'terraform' + @logger = opts[:logger] + @stdin = opts[:stdin] + @stdout = opts[:stdout] + @stderr = opts[:stderr] @execution_mode = opts[:execution_mode] || :in_place end def execute(overrides = {}, &block) parameters = with_configuration_provider_parameters(overrides) @@ -87,23 +98,22 @@ def destroy(parameters) destroy_command.execute(destroy_parameters(parameters)) end def init_command - RubyTerraform::Commands::Init.new(binary: binary) + RubyTerraform::Commands::Init.new(command_options) end def destroy_command - RubyTerraform::Commands::Destroy.new(binary: binary) + RubyTerraform::Commands::Destroy.new(command_options) end def init_parameters(parameters) - init_parameters = - parameters.merge( - chdir: parameters[:configuration_directory], - input: false - ) + init_parameters = parameters.merge( + chdir: parameters[:configuration_directory], + input: false + ) if execution_mode == :isolated init_parameters = init_parameters.merge(from_module: parameters[:source_directory]) end @@ -125,9 +135,20 @@ end destroy_parameters end # rubocop:enable Metrics/MethodLength + + def command_options + { + binary: binary, + logger: logger, + stdin: stdin, + stdout: stdout, + stderr: stderr + } + end end + # rubocop:enable Metrics/ClassLength end end end