Sha256: f55f546b67cf0f178eb32bbc2c58dfdc2a6b17eb446793de4d62c011ab0d3d13

Contents?: true

Size: 736 Bytes

Versions: 43

Compression:

Stored size: 736 Bytes

Contents

require 'securerandom'

class Terraspace::CLI
  class Up < Base
    include TfcConcern

    def run
      build
      if @options[:yes] && !@options[:plan] && !tfc?
        plan
        Commander.new("apply", @options.merge(plan: plan_path)).run
      else
        Commander.new("apply", @options).run
      end
    end

  private
    # must build to compute tfc?
    def build
      Terraspace::Builder.new(@options).run
      @options[:build] = false
    end

    def plan
      FileUtils.mkdir_p(File.dirname(plan_path))
      Commander.new("plan", @options.merge(out: plan_path)).run
    end

    def plan_path
      @@random ||= SecureRandom.hex
      "#{Terraspace.tmp_root}/plans/#{@mod.name}-#{@@random}.plan"
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
terraspace-0.6.0 lib/terraspace/cli/up.rb
terraspace-0.5.12 lib/terraspace/cli/up.rb
terraspace-0.5.11 lib/terraspace/cli/up.rb