Sha256: 0221acb290a0dee806a9db471eb35f566bf12cfe3cf6c1d14301085cc3449061

Contents?: true

Size: 1.23 KB

Versions: 20

Compression:

Stored size: 1.23 KB

Contents

# The placeholder stack is a special stack that is useful in case there are no app/stacks.
# We build a placeholder back just so we have backend.tf to be used to grab info.
# It's useful for the summary command.
module Terraspace::CLI::Build
  class Placeholder
    include Terraspace::Util::Logging

    def initialize(options={})
      @options = options
    end

    # Grab the last module and build that.
    # Assume the backend key has the same prefix
    # Note: Tried building a empty "null" stack but with TFC a null space workspace is created, which is undesired.
    def build
      return if ENV['TS_SUMMARY_BUILD'] == '0'

      mod = @options[:mod]
      if !mod or %w[placeholder].include?(mod)
        logger.info "Building one of the modules to get backend.tf info"
        mod = find_mod
      end
      Terraspace::Builder.new(@options.merge(mod: mod, init: false)).run # generate and init
      Terraspace::Mod.new(mod, @options) # mod metadata
    end

    # Used by: terraspace build placeholder
    def find_mod
      mod_path = Dir.glob("{app,vendor}/{modules,stacks}/*").last
      unless mod_path
        logger.info "No modules or stacks found."
        exit 0
      end
      File.basename(mod_path) # mod name
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
terraspace-0.5.7 lib/terraspace/cli/build/placeholder.rb
terraspace-0.5.6 lib/terraspace/cli/build/placeholder.rb
terraspace-0.5.5 lib/terraspace/cli/build/placeholder.rb
terraspace-0.5.4 lib/terraspace/cli/build/placeholder.rb
terraspace-0.5.3 lib/terraspace/cli/build/placeholder.rb
terraspace-0.5.2 lib/terraspace/cli/build/placeholder.rb
terraspace-0.5.1 lib/terraspace/cli/build/placeholder.rb
terraspace-0.5.0 lib/terraspace/cli/build/placeholder.rb
terraspace-0.4.4 lib/terraspace/cli/build/placeholder.rb
terraspace-0.4.3 lib/terraspace/cli/build/placeholder.rb
terraspace-0.4.2 lib/terraspace/cli/build/placeholder.rb
terraspace-0.4.1 lib/terraspace/cli/build/placeholder.rb
terraspace-0.4.0 lib/terraspace/cli/build/placeholder.rb
terraspace-0.3.6 lib/terraspace/cli/build/placeholder.rb
terraspace-0.3.5 lib/terraspace/cli/build/placeholder.rb
terraspace-0.3.4 lib/terraspace/cli/build/placeholder.rb
terraspace-0.3.3 lib/terraspace/cli/build/placeholder.rb
terraspace-0.3.2 lib/terraspace/cli/build/placeholder.rb
terraspace-0.3.1 lib/terraspace/cli/build/placeholder.rb
terraspace-0.3.0 lib/terraspace/cli/build/placeholder.rb