Class: Kitchen::Terraform::OutputsParser

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/terraform/outputs_parser.rb

Overview

OutputsParser parses Terraform output variables as JSON.

Instance Method Summary collapse

Instance Method Details

#parse(json_outputs:) {|parsed_outputs| ... } ⇒ self

#parse parses the outputs.

Parameters:

  • json_outputs (String)

    the output variables as a string of JSON.

Yield Parameters:

  • parsed_outputs (Hash)

    the output variables as a hash.

Returns:

  • (self)

Raises:

  • (Kitchen::TransientFailure)

    if parsing the output variables fails.



30
31
32
33
34
35
36
# File 'lib/kitchen/terraform/outputs_parser.rb', line 30

def parse(json_outputs:)
  yield parsed_outputs: ::JSON.parse(json_outputs)

  self
rescue ::JSON::ParserError
  raise ::Kitchen::TransientFailure, "Parsing the Terraform output variables as JSON failed."
end