Sha256: cdaaf5be5a852e6a941139703bd0f11774423b6e176eae73a4f4c68485fabd00
Contents?: true
Size: 1.34 KB
Versions: 4
Compression:
Stored size: 1.34 KB
Contents
module Terraforming module Util def apply_template(client, erb) ERB.new(open(template_path(erb)).read, nil, "-").result(binding) end def name_from_tag(resource, default_name) name_tag = resource.tags.find { |tag| tag.key == "Name" } name_tag ? name_tag.value : default_name end def normalize_module_name(name) name.gsub(/[^a-zA-Z0-9_-]/, "-") end def template_path(template_name) File.join(File.expand_path(File.dirname(__FILE__)), "template", template_name) << ".erb" end def generate_tfstate(resources, tfstate_base = nil) tfstate = tfstate_base || tfstate_skeleton tfstate["serial"] = tfstate["serial"] + 1 tfstate["modules"][0]["resources"] = tfstate["modules"][0]["resources"].merge(resources) JSON.pretty_generate(tfstate) end def prettify_policy(policy_document, breakline = false) json = JSON.pretty_generate(JSON.parse(CGI.unescape(policy_document))) if breakline json[-1] != "\n" ? json << "\n" : json else json.strip end end def tfstate_skeleton { "version" => 1, "serial" => 0, "modules" => [ { "path" => [ "root" ], "outputs" => {}, "resources" => {}, } ] } end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
terraforming-0.1.3 | lib/terraforming/util.rb |
terraforming-0.1.2 | lib/terraforming/util.rb |
terraforming-0.1.1 | lib/terraforming/util.rb |
terraforming-0.1.0 | lib/terraforming/util.rb |