lib/rspec/terraform/helpers/actions/apply.rb in rspec-terraform-0.1.0.pre.47 vs lib/rspec/terraform/helpers/actions/apply.rb in rspec-terraform-0.1.0.pre.48

- old
+ new

@@ -10,15 +10,37 @@ module Actions module Apply include CommandInstantiation def apply(parameters) - apply_command.execute(apply_parameters(parameters)) + parameters = apply_parameters(parameters) + + log_apply_starting(parameters) + log_apply_using_parameters(parameters) + + apply_command.execute(parameters) + + log_apply_complete end private + def log_apply_starting(parameters) + logger&.info( + 'Applying for configuration in directory: ' \ + "'#{parameters[:chdir]}'..." + ) + end + + def log_apply_using_parameters(parameters) + logger&.debug("Applying using parameters: #{parameters}...") + end + + def log_apply_complete + logger&.info('Apply complete.') + end + def apply_command instantiate_command(RubyTerraform::Commands::Apply) end def apply_parameters(parameters) @@ -26,19 +48,26 @@ with_apply_standard_parameters(parameters) ) end def with_apply_standard_parameters(parameters) - parameters.merge( - chdir: parameters[:configuration_directory], - input: false, - auto_approve: true - ) + configuration_directory = parameters[:configuration_directory] + + parameters + .except(:configuration_directory) + .merge( + chdir: configuration_directory, + input: false, + auto_approve: true + ) end def with_apply_state_file_parameters(parameters) - if parameters[:state_file] - return parameters.merge(state: parameters[:state_file]) + state_file = parameters[:state_file] + if state_file + return parameters + .except(:state_file) + .merge(state: state_file) end parameters end end