Class: Terraspace::Terraform::Tfc::Syncer

Inherits:
CLI::Base
  • Object
show all
Extended by:
Memoist
Includes:
Compiler::DirsConcern, Util::Sure
Defined in:
lib/terraspace/terraform/tfc/syncer.rb

Instance Method Summary collapse

Methods included from Util::Sure

#sure?

Methods included from Compiler::DirsConcern

#cache_dirs, #dirs, #local_paths, #mod_names, #select_stack?, #stack_names, #with_each_mod

Methods inherited from CLI::Base

#initialize

Methods included from Util::Pretty

#pretty_path, #pretty_time

Methods included from Util::Logging

#logger

Constructor Details

This class inherits a constructor from Terraspace::CLI::Base

Instance Method Details

#are_you_sure?Boolean

Returns:

  • (Boolean)


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/terraspace/terraform/tfc/syncer.rb', line 28

def are_you_sure?
  message ="    About to sync these project stacks with Terraform Cloud workspaces:\n\n        Stack => Workspace\n  EOL\n\n  mods.each do |mod|\n    sync = sync(mod)\n    message << \"    \#{mod} => \#{sync.workspace_name}\\n\"\n  end\n  message << <<~EOL\n\n    A sync does the following for each workspace:\n\n      1. Create or update workspace, including the VCS settings.\n      2. Set the working dir.\n      3. Set env and terraform variables.\n\n    Are you sure?\n  EOL\n  sure?(message.chop)\nend\n"

#modsObject



14
15
16
17
# File 'lib/terraspace/terraform/tfc/syncer.rb', line 14

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

#runObject



7
8
9
10
11
12
# 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) ⇒ Object



19
20
21
# File 'lib/terraspace/terraform/tfc/syncer.rb', line 19

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

#sync(mod) ⇒ Object



23
24
25
# File 'lib/terraspace/terraform/tfc/syncer.rb', line 23

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