Sha256: 4d031267df763ed444beda12fff3d1f60529babc76a6b018ffcd06896f706897

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 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
      mod = @options[:mod]
      mod ? [mod] : stack_names
    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

4 entries across 4 versions & 1 rubygems

Version Path
terraspace-0.3.3 lib/terraspace/terraform/cloud/syncer.rb
terraspace-0.3.2 lib/terraspace/terraform/cloud/syncer.rb
terraspace-0.3.1 lib/terraspace/terraform/cloud/syncer.rb
terraspace-0.3.0 lib/terraspace/terraform/cloud/syncer.rb