Class: Pangea::CLI::Synthesizer

Inherits:
Object
  • Object
show all
Defined in:
lib/pangea/cli/synthesizer.rb

Overview

Synthesizes a Pangea Ruby template into Terraform JSON. Loads the template, evaluates it on a TerraformSynthesizer, injects the backend config, and returns the manifest.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Synthesizer

Returns a new instance of Synthesizer.



13
14
15
# File 'lib/pangea/cli/synthesizer.rb', line 13

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



11
12
13
# File 'lib/pangea/cli/synthesizer.rb', line 11

def config
  @config
end

Instance Method Details

#synthesizeHash

Returns Normalized Terraform manifest with string keys.

Returns:

  • (Hash)

    Normalized Terraform manifest with string keys



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/pangea/cli/synthesizer.rb', line 18

def synthesize
  load_workspace_libs
  load_synthesizer_gem

  synth = TerraformSynthesizer.new
  block = capture_template_block(config.template_content, config.template_file)

  if block
    synth.instance_eval(&block)
  else
    $stderr.puts "[pangea] Warning: no template block found, trying direct eval"
    synth.instance_eval(config.template_content, config.template_file)
  end

  manifest = normalize(synth.synthesis)
  inject_backend(manifest)
  manifest
end