Class: RubyTerraform::Commands::Base
- Inherits:
-
Object
- Object
- RubyTerraform::Commands::Base
- Defined in:
- lib/ruby_terraform/commands/base.rb
Direct Known Subclasses
Apply, Destroy, ForceUnlock, Format, Get, Graph, Import, Init, Login, Logout, Output, Plan, Providers, ProvidersLock, ProvidersMirror, ProvidersSchema, Refresh, Show, StateList, StateMove, StatePull, StatePush, StateRemove, StateReplaceProvider, StateShow, Taint, Untaint, Validate, WorkspaceDelete, WorkspaceList, WorkspaceNew, WorkspaceSelect, WorkspaceShow
Instance Method Summary collapse
-
#execute(parameters = {}, invocation_options = {}) ⇒ Object
Executes the command instance.
-
#initialize(opts = {}) ⇒ Base
constructor
Constructs an instance of the command.
Constructor Details
#initialize(opts = {}) ⇒ Base
Constructs an instance of the command.
15 16 17 18 19 20 21 22 |
# File 'lib/ruby_terraform/commands/base.rb', line 15 def initialize(opts = {}) @binary = opts[:binary] || RubyTerraform.configuration.binary @logger = opts[:logger] || RubyTerraform.configuration.logger @options = opts[:options] || RubyTerraform.configuration. @stdin = opts[:stdin] || RubyTerraform.configuration.stdin @stdout = opts[:stdout] || RubyTerraform.configuration.stdout @stderr = opts[:stderr] || RubyTerraform.configuration.stderr end |
Instance Method Details
#execute(parameters = {}, invocation_options = {}) ⇒ Object
Executes the command instance.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ruby_terraform/commands/base.rb', line 35 def execute(parameters = {}, = {}) parameters = resolve_parameters(parameters) = () do_before(parameters) result = build_and_execute_command(parameters, ) do_after(parameters) prepare_result(result, parameters, ) rescue Lino::Errors::ExecutionError = "Failed while running '#{command_name}'." logger.error() raise Errors::ExecutionError, end |