Sha256: c00d1f3176393d8e1cf0431a9ef512e0cad27599beb87d3fc91a860020ba0bd9

Contents?: true

Size: 1.03 KB

Versions: 6

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

require 'ruby_terraform'

require_relative 'base'
require_relative 'actions'

module RSpec
  module Terraform
    module Helpers
      class Output < Base
        include Actions::Validate
        include Actions::Clean
        include Actions::Init
        include Actions::Output

        def execute(overrides = {})
          parameters = resolve_parameters(overrides)

          validate(parameters)
          clean(parameters)
          init(parameters)
          output_value = output(parameters)

          parse(output_value)
        end

        private

        def mandatory_parameters
          {
            json: true
          }
        end

        def required_parameters(execution_mode)
          {
            in_place: %i[name configuration_directory],
            isolated: %i[name source_directory configuration_directory]
          }[execution_mode] || []
        end

        def parse(output_value)
          JSON.parse(output_value, symbolize_names: true)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rspec-terraform-0.5.0.pre.9 lib/rspec/terraform/helpers/output.rb
rspec-terraform-0.5.0.pre.8 lib/rspec/terraform/helpers/output.rb
rspec-terraform-0.5.0.pre.7 lib/rspec/terraform/helpers/output.rb
rspec-terraform-0.5.0.pre.6 lib/rspec/terraform/helpers/output.rb
rspec-terraform-0.5.0.pre.5 lib/rspec/terraform/helpers/output.rb
rspec-terraform-0.5.0.pre.4 lib/rspec/terraform/helpers/output.rb