Sha256: 75301171a558e27112f28ca6a933384f35916a3a919d4a0ddb5e9fe95e15425f
Contents?: true
Size: 1.02 KB
Versions: 14
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true require_relative '../configuration/var_captor' module RSpec module Terraform module Helpers class Var attr_reader(:configuration_provider) def initialize(opts = {}) @configuration_provider = opts[:configuration_provider] || Configuration.identity_provider end def execute(overrides = {}, &block) parameters = with_configuration_provider_parameters(overrides) parameters = with_resolved_vars(parameters, &block) parameters[:vars][parameters[:name].to_sym] end private 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 end end end end
Version data entries
14 entries across 14 versions & 1 rubygems