Class: Capistrano::Terraforms

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano/terraform/terraforms.rb

Class Method Summary collapse

Class Method Details

.allObject



55
56
57
58
# File 'lib/capistrano/terraform/terraforms.rb', line 55

def self.all
  @@terraforms ||= {} # auto-init class variable on usage
  return @@terraforms
end

.deployObject



28
29
30
# File 'lib/capistrano/terraform/terraforms.rb', line 28

def self.deploy
  fetch :terraform_deploy, true
end

.find(terraform_id) ⇒ Object



60
61
62
# File 'lib/capistrano/terraform/terraforms.rb', line 60

def self.find(terraform_id)
  return all[terraform_id]
end

.rootObject



12
13
14
# File 'lib/capistrano/terraform/terraforms.rb', line 12

def self.root
  fetch :terraform_root, nil
end

.root_pathObject



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/capistrano/terraform/terraforms.rb', line 32

def self.root_path
  if roles(:terraform).first
    return deploy_path.join(fetch(:current_directory, 'current')).join(fetch(:terraform_root, '.'))
  else
    return Pathname.new(fetch(:terraform_root, '.'))
  end

  # return deploy_path.join(fetch(:current_directory, 'current')) if build_dir.nil?
  # return Pathname.new(build_dir.strip) if build_dir.strip[0] == '/'
  # return deploy_path.join(fetch(:current_directory, 'current'), build_dir)
end

.targetsObject



24
25
26
# File 'lib/capistrano/terraform/terraforms.rb', line 24

def self.targets
  [fetch(:terraform_target, [])].flatten.uniq
end

.terraform_cmdObject



8
9
10
# File 'lib/capistrano/terraform/terraforms.rb', line 8

def self.terraform_cmd
  fetch(:terraform_cmd, :terraform)
end

.upsert(terraform_id, params = {}) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'lib/capistrano/terraform/terraforms.rb', line 44

def self.upsert(terraform_id, params = {})
  @@terraforms ||= {} # auto-init class variable on usage
  terraform_id = terraform_id.to_sym
  if @@terraforms.key?(terraform_id)
    @@terraforms[terraform_id].update(params)
  else
    @@terraforms[terraform_id] = ::Capistrano::Terraform.new(params)
    @@terraforms[terraform_id].create_tasks(terraform_id)
  end
end

.var_filesObject



20
21
22
# File 'lib/capistrano/terraform/terraforms.rb', line 20

def self.var_files
  fetch(:terraform_var_file, []).uniq
end

.varsObject



16
17
18
# File 'lib/capistrano/terraform/terraforms.rb', line 16

def self.vars
  fetch :terraform_var, []
end