Module: Pangea::Outputs
- Defined in:
- lib/pangea/outputs.rb
Overview
Output category management for Terraform templates.
Outputs are classified into categories that can be independently toggled:
:display — Human-readable info (cluster_name, backend type)
:data — Machine-consumable values for cross-template wiring (vpc_id, role_arn)
Configuration is set on the synthesizer context before outputs are declared:
# In template:
self.pangea_output_config = { display: true, data: true } # default: all on
self.pangea_output_config = { display: false, data: true } # suppress display
self.pangea_output_config = { display: false, data: false } # suppress all
pangea_output :cluster_name, category: :display do
value cluster_name
description "K3s cluster name"
end
pangea_output :vpc_id, category: :data do
value result.network.vpc.id
description "VPC ID"
end
When a category is disabled, the output block is not emitted to Terraform JSON.
Constant Summary collapse
- DEFAULT_CONFIG =
Default: all outputs enabled
{ display: true, data: true }.freeze
Instance Method Summary collapse
-
#data_output(name, &block) ⇒ Object
Convenience: declare a data output (for cross-template wiring).
-
#display_output(name, &block) ⇒ Object
Convenience: declare a display-only output.
-
#enable_all_outputs! ⇒ Object
Enable all outputs (default state).
-
#pangea_output(name, category: :data, &block) ⇒ Object
Declare a categorized output.
-
#pangea_output_config ⇒ Object
Get current output configuration.
-
#pangea_output_config=(config) ⇒ Object
Set output rendering configuration.
-
#suppress_all_outputs! ⇒ Object
Suppress all outputs (useful for module mode where outputs are internal).
-
#suppress_display_outputs! ⇒ Object
Suppress only display outputs (keep data for wiring).
Instance Method Details
#data_output(name, &block) ⇒ Object
Convenience: declare a data output (for cross-template wiring).
72 73 74 |
# File 'lib/pangea/outputs.rb', line 72 def data_output(name, &block) pangea_output(name, category: :data, &block) end |
#display_output(name, &block) ⇒ Object
Convenience: declare a display-only output.
67 68 69 |
# File 'lib/pangea/outputs.rb', line 67 def display_output(name, &block) pangea_output(name, category: :display, &block) end |
#enable_all_outputs! ⇒ Object
Enable all outputs (default state).
87 88 89 |
# File 'lib/pangea/outputs.rb', line 87 def enable_all_outputs! self.pangea_output_config = { display: true, data: true } end |
#pangea_output(name, category: :data, &block) ⇒ Object
Declare a categorized output.
The output is only emitted if its category is enabled in pangea_output_config. If no category is specified, defaults to :data (always emitted unless data is off).
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/pangea/outputs.rb', line 53 def pangea_output(name, category: :data, &block) config = pangea_output_config # Master kill switch: if ALL categories are off, emit nothing return if config.values.none? # Category-specific toggle return unless config.fetch(category, true) # Delegate to the synthesizer's native output method output(name, &block) end |
#pangea_output_config ⇒ Object
Get current output configuration.
41 42 43 |
# File 'lib/pangea/outputs.rb', line 41 def pangea_output_config @_pangea_output_config || DEFAULT_CONFIG.dup end |
#pangea_output_config=(config) ⇒ Object
Set output rendering configuration. Called on the synthesizer context (self in a template).
36 37 38 |
# File 'lib/pangea/outputs.rb', line 36 def pangea_output_config=(config) @_pangea_output_config = DEFAULT_CONFIG.merge(config) end |
#suppress_all_outputs! ⇒ Object
Suppress all outputs (useful for module mode where outputs are internal).
77 78 79 |
# File 'lib/pangea/outputs.rb', line 77 def suppress_all_outputs! self.pangea_output_config = { display: false, data: false } end |
#suppress_display_outputs! ⇒ Object
Suppress only display outputs (keep data for wiring).
82 83 84 |
# File 'lib/pangea/outputs.rb', line 82 def suppress_display_outputs! self.pangea_output_config = { display: false, data: true } end |