Class: Terraspace::Terraform::Tfc::Syncer
Instance Method Summary
collapse
Methods included from Util::Sure
#sure?
#cache_dirs, #dirs, #extract_stack_name, #local_paths, #mod_names, #select_stack?, #stack_names, #with_each_mod
Methods inherited from CLI::Base
#initialize
#pretty_path, #pretty_time
#logger
Instance Method Details
#are_you_sure? ⇒ 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 =<<~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 ⇒ Object
14
15
16
17
|
# File 'lib/terraspace/terraform/tfc/syncer.rb', line 14
def mods
stacks = @options[:stacks]
stacks.empty? ? stack_names : stacks
end
|
#run ⇒ Object
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
|