Sha256: a4a126b69f0d25dfa6513fee0d04e8958f02b7d60270fb0b4075ea1ae795a179

Contents?: true

Size: 1.12 KB

Versions: 9

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

require_relative './base'
require_relative './actions'

module RSpec
  module Terraform
    module Helpers
      class Plan < Base
        include Actions::Validate
        include Actions::Clean
        include Actions::Init
        include Actions::Plan
        include Actions::Show
        include Actions::Remove

        def execute(overrides = {}, &block)
          parameters = resolve_parameters(overrides, &block)

          validate(parameters)
          clean(parameters)
          init(parameters)
          plan_file = plan(parameters)
          plan_contents = show(parameters, plan_file)
          remove(parameters, plan_file)
          parse(plan_contents)
        end

        private

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

        def parse(plan_contents)
          RubyTerraform::Models::Plan.new(
            JSON.parse(plan_contents, symbolize_names: true)
          )
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rspec-terraform-0.5.0.pre.3 lib/rspec/terraform/helpers/plan.rb
rspec-terraform-0.5.0.pre.2 lib/rspec/terraform/helpers/plan.rb
rspec-terraform-0.5.0.pre.1 lib/rspec/terraform/helpers/plan.rb
rspec-terraform-0.4.0 lib/rspec/terraform/helpers/plan.rb
rspec-terraform-0.3.0.pre.1 lib/rspec/terraform/helpers/plan.rb
rspec-terraform-0.2.0 lib/rspec/terraform/helpers/plan.rb
rspec-terraform-0.1.0.pre.49 lib/rspec/terraform/helpers/plan.rb
rspec-terraform-0.1.0.pre.48 lib/rspec/terraform/helpers/plan.rb
rspec-terraform-0.1.0.pre.47 lib/rspec/terraform/helpers/plan.rb