Class: Terraspace::Terraform::Api::Vars::Json
- Inherits:
-
Base
- Object
- Base
- Terraspace::Terraform::Api::Vars::Json
show all
- Defined in:
- lib/terraspace/terraform/api/vars/json.rb
Instance Method Summary
collapse
Methods inherited from Base
#initialize
#logger
Instance Method Details
#json_load(result) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/terraspace/terraform/api/vars/json.rb', line 14
def json_load(result)
JSON.load(result)
rescue JSON::ParserError => e
logger.info("ERROR in json: #{e.class}: #{e.message}")
path = "#{Terraspace.tmp_root}/terraspace/debug/vars.json"
logger.info("Result also written to #{path} for inspection")
FileUtils.mkdir_p(File.dirname(path))
IO.write(path, result)
exit 1
end
|
#vars ⇒ Object
3
4
5
6
7
8
9
10
11
12
|
# File 'lib/terraspace/terraform/api/vars/json.rb', line 3
def vars
context = Terraspace::Compiler::Erb::Context.new(@mod)
result = RenderMePretty.result(@vars_path, context: context)
data = json_load(result)
items = data.select do |item|
item['data']['type'] == 'vars'
end
items.map { |i| i['data']['attributes'] }
end
|