Class: Sfn::Command::Graph::Provider::Terraform::TerraformGraphProcessor
- Inherits:
-
SparkleFormation::Translation
- Object
- SparkleFormation::Translation
- Sfn::Command::Graph::Provider::Terraform::TerraformGraphProcessor
- Defined in:
- lib/sfn/command/graph/terraform.rb
Constant Summary collapse
- MAP =
{}
- REF_MAPPING =
{}
- FN_MAPPING =
{}
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #apply_function(string, funcs = []) ⇒ Object
- #dereference_processor(obj, funcs = []) ⇒ Object
-
#initialize(template, args = {}) ⇒ TerraformGraphProcessor
constructor
A new instance of TerraformGraphProcessor.
- #outputs ⇒ Object
- #parameters ⇒ Object
- #resources ⇒ Object
Constructor Details
#initialize(template, args = {}) ⇒ TerraformGraphProcessor
Returns a new instance of TerraformGraphProcessor.
16 17 18 19 |
# File 'lib/sfn/command/graph/terraform.rb', line 16 def initialize(template, args = {}) super @name = args[:name] end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
14 15 16 |
# File 'lib/sfn/command/graph/terraform.rb', line 14 def name @name end |
Instance Method Details
#apply_function(string, funcs = []) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/sfn/command/graph/terraform.rb', line 53 def apply_function(string, funcs = []) # first check for vars and replace with params string.scan(/(\$\{var\.(.+?)\})/).each do |match| if parameters[match.last] string.sub!(match.first, parameters[match.last]) end end string end |
#dereference_processor(obj, funcs = []) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sfn/command/graph/terraform.rb', line 21 def dereference_processor(obj, funcs = []) case obj when Array obj = obj.map { |v| dereference_processor(v, funcs) } when Hash new_hash = {} obj.each do |k, v| new_hash[k] = dereference_processor(v, funcs) end obj = new_hash when String obj = apply_function(obj, funcs) end obj end |
#outputs ⇒ Object
49 50 51 |
# File 'lib/sfn/command/graph/terraform.rb', line 49 def outputs @original.fetch("outputs", {}) end |
#parameters ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/sfn/command/graph/terraform.rb', line 37 def parameters Hash[ @original.fetch("parameters", {}).map do |k, v| [k, v.fetch("default", "")] end ].merge(@parameters) end |
#resources ⇒ Object
45 46 47 |
# File 'lib/sfn/command/graph/terraform.rb', line 45 def resources @original.fetch("resources", {}) end |