Class: Terraspace::Terraform::Api::Vars
- Inherits:
-
Object
- Object
- Terraspace::Terraform::Api::Vars
- Extended by:
- Memoist
- Includes:
- Http::Concern
- Defined in:
- lib/terraspace/terraform/api/vars.rb,
lib/terraspace/terraform/api/vars/rb.rb,
lib/terraspace/terraform/api/vars/base.rb,
lib/terraspace/terraform/api/vars/json.rb
Defined Under Namespace
Instance Method Summary collapse
- #exist? ⇒ Boolean
-
#initialize(mod, workspace) ⇒ Vars
constructor
workspace: details from the api response.
- #run ⇒ Object
-
#vars_class ⇒ Object
Return value examples:.
- #vars_path ⇒ Object
Methods included from Http::Concern
Constructor Details
#initialize(mod, workspace) ⇒ Vars
workspace: details from the api response
7 8 9 |
# File 'lib/terraspace/terraform/api/vars.rb', line 7 def initialize(mod, workspace) @mod, @workspace = mod, workspace end |
Instance Method Details
#exist? ⇒ Boolean
30 31 32 |
# File 'lib/terraspace/terraform/api/vars.rb', line 30 def exist? !!vars_path end |
#run ⇒ Object
11 12 13 14 15 16 17 18 |
# 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 ⇒ Object
Return value examples:
Terraspace::Terraform::Api::Vars::Json
Terraspace::Terraform::Api::Vars::Rb
25 26 27 28 |
# 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 ⇒ Object
34 35 36 37 |
# 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 |