Sha256: a71ccffc01fb9567148779086d67c8a6c063800f42c4267733b476802d10d734

Contents?: true

Size: 1.3 KB

Versions: 53

Compression:

Stored size: 1.3 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".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

53 entries across 53 versions & 1 rubygems

Version Path
terraspace-0.6.12 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-0.6.11 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-0.6.10 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-0.6.9 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-0.6.8 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-0.6.7 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-0.6.6 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-0.6.5 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-0.6.4 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-0.6.3 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-0.6.2 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-0.6.1 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-0.6.0 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-0.5.12 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-0.5.11 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-0.5.10 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-0.5.9 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-0.5.8 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-0.5.7 lib/terraspace/terraform/remote_state/marker/output.rb
terraspace-0.5.6 lib/terraspace/terraform/remote_state/marker/output.rb