Sha256: 6a34df7a0beb879d2dc331eca2407b40af44f9d131dc90d3167d6deee3804cb7

Contents?: true

Size: 1.39 KB

Versions: 38

Compression:

Stored size: 1.39 KB

Contents

module Terraspace::Terraform::RemoteState::Marker
  class Output
    include Terraspace::Util::Logging

    def initialize(mod, identifier, options={})
      @mod, @identifier, @options = mod, identifier, options
      @parent_name = @mod.name
      @child_name, @output_key = @identifier.split('.')
    end

    # Returns OutputProxy
    def build
      if valid?
        Terraspace::Dependency::Registry.register(@parent_name, @child_name)
      else
        warning
      end
      # MARKER for debugging. Only appears on 1st pass. Will not see unless changing Terraspace code for debugging.
      marker = "MARKER:terraform_output('#{@identifier}')"
      Terraspace::Terraform::RemoteState::OutputProxy.new(@mod, marker, @options)
    end

    def valid?
      self.class.stack_names.include?(@child_name)
    end

    def warning
      logger.warn "WARN: The #{@child_name} stack does not exist or is configured to be not included. IE: config.all.include_stacks or config.all.exclude_stacks".color(:yellow)
      caller_line = caller.find { |l| l.include?('.tfvars') }
      return unless caller_line # specs dont have a tfvars file
      source_code = PrettyTracer.new(caller_line).source_code
      logger.info source_code
    end

    class << self
      extend Memoist
      # Marker::Output uses DirsConcern stack_names to check if stacks are valid
      include Terraspace::Compiler::DirsConcern
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
terraspace-2.2.17 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-2.2.16 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-2.2.15 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-2.2.14 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-2.2.13 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-2.2.12 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-2.2.11 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-2.2.10 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-2.2.9 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-2.2.8 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-2.2.7 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-2.2.6 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-2.2.5 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-2.2.4 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-2.2.3 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-2.2.2 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-2.2.1 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-2.2.0 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-2.1.7 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-2.1.6 lib/terraspace/terraform/remote_state/marker/output.rb