class Terraspace::Terraform::Tfc::Syncer

Public Instance Methods

are_you_sure?() click to toggle source
# File lib/terraspace/terraform/tfc/syncer.rb, line 28
    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
mods() click to toggle source
# File lib/terraspace/terraform/tfc/syncer.rb, line 14
def mods
  stacks = @options[:stacks]
  stacks.empty? ? stack_names : stacks
end
run() click to toggle source
# File lib/terraspace/terraform/tfc/syncer.rb, line 7
def run
  are_you_sure?
  mods.each do |mod|
    run_sync(mod)
  end
end
run_sync(mod) click to toggle source
# File lib/terraspace/terraform/tfc/syncer.rb, line 19
def run_sync(mod)
  sync(mod).run
end
sync(mod) click to toggle source
# File lib/terraspace/terraform/tfc/syncer.rb, line 23
def sync(mod)
  Sync.new(@options.merge(mod: mod))
end