Module: Terrafying::Util

Defined in:
lib/terrafying/util.rb

Class Method Summary collapse

Class Method Details

.to_ignition(yaml) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/terrafying/util.rb', line 13

def self.to_ignition(yaml)
  config = YAML.load(yaml)

  if config.has_key? "storage" and config["storage"].has_key? "files"
    files = config["storage"]["files"]
    config["storage"]["files"] = files.each { |file|
      if file["contents"].is_a? String
        file["contents"] = {
          source: data_url_from_string(file["contents"]),
        }
      end
    }
  end

  JSON.pretty_generate(config)
end