class Kitchen::Terraform::OutputsReader
OutputsReader
is the class of objects which read Terraform
output variables.
Attributes
command_executor[RW]
no_outputs_defined[RW]
Public Class Methods
new(command_executor:)
click to toggle source
initialize prepares a new instance of the class.
@param command_executor
[Kitchen::Terraform::CommandExecutor] an executor to run the output command. @return [Kitchen::Terraform::OutputsReader]
# File lib/kitchen/terraform/outputs_reader.rb, line 41 def initialize(command_executor:) self.command_executor = command_executor self.no_outputs_defined = /no\\ outputs\\ defined/ end
Public Instance Methods
read(command:, options:) { |json_outputs: json_outputs| ... }
click to toggle source
read
reads the output variables.
@param command [Kitchen::Terraform::Command::Output] the output command. @raise [Kitchen::TransientFailure] if running the output command fails. @yieldparam json_outputs [String] the output variables as a string of JSON. @return [self]
# File lib/kitchen/terraform/outputs_reader.rb, line 29 def read(command:, options:) run command: command, options: options do |json_outputs:| yield json_outputs: json_outputs end self end
Private Instance Methods
run(command:, options:) { |json_outputs: standard_output| ... }
click to toggle source
# File lib/kitchen/terraform/outputs_reader.rb, line 50 def run(command:, options:) command_executor.run command: command, options: options do |standard_output| yield json_outputs: standard_output end rescue ::Kitchen::TransientFailure => error if no_outputs_defined.match ::Regexp.escape error.original.to_s yield json_outputs: "{}" else raise error end end