Sha256: 98ac54bae0e0e15eb8ded5d317972b20ebd62934e1cb3781f649c20d73d35595

Contents?: true

Size: 1.07 KB

Versions: 21

Compression:

Stored size: 1.07 KB

Contents

module Terraspace::Terraform::Cloud
  class Syncer < Terraspace::CLI::Base
    extend Memoist
    include Terraspace::Compiler::DirsConcern
    include Terraspace::Util::Sure

    def run
      are_you_sure?
      mods.each do |mod|
        run_sync(mod)
      end
    end

    def mods
      stacks = @options[:stacks]
      stacks.empty? ? stack_names : stacks
    end

    def run_sync(mod)
      sync(mod).run
    end

    def sync(mod)
      Sync.new(@options.merge(mod: mod))
    end
    memoize :sync

    def are_you_sure?
      message =<<~EOL
        About to sync these project stacks with Terraform Cloud workspaces:

            Stack => Workspace
      EOL

      mods.each do |mod|
        sync = sync(mod)
        message << "    #{mod} => #{sync.workspace_name}\n"
      end
      message << <<~EOL

        A sync does the following for each workspace:

          1. Create or update workspace, including the VCS settings.
          2. Set the working dir.
          3. Set env and terraform variables.

        Are you sure?
      EOL
      sure?(message.chop)
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
terraspace-0.5.12 lib/terraspace/terraform/cloud/syncer.rb
terraspace-0.5.11 lib/terraspace/terraform/cloud/syncer.rb
terraspace-0.5.10 lib/terraspace/terraform/cloud/syncer.rb
terraspace-0.5.9 lib/terraspace/terraform/cloud/syncer.rb
terraspace-0.5.8 lib/terraspace/terraform/cloud/syncer.rb
terraspace-0.5.7 lib/terraspace/terraform/cloud/syncer.rb
terraspace-0.5.6 lib/terraspace/terraform/cloud/syncer.rb
terraspace-0.5.5 lib/terraspace/terraform/cloud/syncer.rb
terraspace-0.5.4 lib/terraspace/terraform/cloud/syncer.rb
terraspace-0.5.3 lib/terraspace/terraform/cloud/syncer.rb
terraspace-0.5.2 lib/terraspace/terraform/cloud/syncer.rb
terraspace-0.5.1 lib/terraspace/terraform/cloud/syncer.rb
terraspace-0.5.0 lib/terraspace/terraform/cloud/syncer.rb
terraspace-0.4.4 lib/terraspace/terraform/cloud/syncer.rb
terraspace-0.4.3 lib/terraspace/terraform/cloud/syncer.rb
terraspace-0.4.2 lib/terraspace/terraform/cloud/syncer.rb
terraspace-0.4.1 lib/terraspace/terraform/cloud/syncer.rb
terraspace-0.4.0 lib/terraspace/terraform/cloud/syncer.rb
terraspace-0.3.6 lib/terraspace/terraform/cloud/syncer.rb
terraspace-0.3.5 lib/terraspace/terraform/cloud/syncer.rb