class Terraspace::Terraform::Api::Vars

Public Class Methods

new(mod, workspace) click to toggle source

workspace: details from the api response

# File lib/terraspace/terraform/api/vars.rb, line 7
def initialize(mod, workspace)
  @mod, @workspace = mod, workspace
end

Public Instance Methods

exist?() click to toggle source
# File lib/terraspace/terraform/api/vars.rb, line 30
def exist?
  !!vars_path
end
run() click to toggle source
# File lib/terraspace/terraform/api/vars.rb, line 11
def run
  return unless exist?

  vars = vars_class.new(@mod, vars_path).vars
  vars.each do |attrs|
    Var.new(@workspace, attrs).sync
  end
end
vars_class() click to toggle source

Return value examples:

Terraspace::Terraform::Api::Vars::Json
Terraspace::Terraform::Api::Vars::Rb
# File lib/terraspace/terraform/api/vars.rb, line 25
def vars_class
  ext = File.extname(vars_path).sub('.','')
  "Terraspace::Terraform::Api::Vars::#{ext.camelize}".constantize
end
vars_path() click to toggle source
# File lib/terraspace/terraform/api/vars.rb, line 34
def vars_path
  # .rb takes higher precedence
  Dir.glob("#{Terraspace.root}/config/terraform/tfc/vars.{rb,json}").first
end