Sha256: 3809702c962a69b7527dc688730b124df1b84b394d0fd4a3d210d67dad4eaa16

Contents?: true

Size: 941 Bytes

Versions: 15

Compression:

Stored size: 941 Bytes

Contents

# frozen_string_literal: true

require_relative '../configuration/var_captor'

module RSpec
  module Terraform
    module Helpers
      module Parameters
        def resolve_parameters(overrides, &block)
          parameters = with_configuration_provider_parameters(overrides)
          parameters = with_resolved_vars(parameters, &block)
          with_mandatory_parameters(parameters)
        end

        def with_configuration_provider_parameters(parameters)
          configuration_provider.resolve(parameters)
        end

        def with_resolved_vars(parameters, &block)
          return parameters unless block_given?

          var_captor = Configuration::VarCaptor.new(parameters[:vars] || {})
          block.call(var_captor)
          parameters.merge(vars: var_captor.to_h)
        end

        def with_mandatory_parameters(parameters)
          parameters.merge(mandatory_parameters)
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
rspec-terraform-0.5.0.pre.8 lib/rspec/terraform/helpers/parameters.rb
rspec-terraform-0.5.0.pre.7 lib/rspec/terraform/helpers/parameters.rb
rspec-terraform-0.5.0.pre.6 lib/rspec/terraform/helpers/parameters.rb
rspec-terraform-0.5.0.pre.5 lib/rspec/terraform/helpers/parameters.rb
rspec-terraform-0.5.0.pre.4 lib/rspec/terraform/helpers/parameters.rb
rspec-terraform-0.5.0.pre.3 lib/rspec/terraform/helpers/parameters.rb
rspec-terraform-0.5.0.pre.2 lib/rspec/terraform/helpers/parameters.rb
rspec-terraform-0.5.0.pre.1 lib/rspec/terraform/helpers/parameters.rb
rspec-terraform-0.4.0 lib/rspec/terraform/helpers/parameters.rb
rspec-terraform-0.3.0.pre.1 lib/rspec/terraform/helpers/parameters.rb
rspec-terraform-0.2.0 lib/rspec/terraform/helpers/parameters.rb
rspec-terraform-0.1.0.pre.49 lib/rspec/terraform/helpers/parameters.rb
rspec-terraform-0.1.0.pre.48 lib/rspec/terraform/helpers/parameters.rb
rspec-terraform-0.1.0.pre.47 lib/rspec/terraform/helpers/parameters.rb
rspec-terraform-0.1.0.pre.46 lib/rspec/terraform/helpers/parameters.rb