Class: Pangea::Testing::ArchitectureSpecGenerator
- Defined in:
- lib/pangea/testing/architecture_spec_generator.rb
Overview
Auto-generates RSpec architecture specs from composition metadata.
Usage:
generator = ArchitectureSpecGenerator.new(
module_name: 'Pangea::Architectures::K3sDevCluster',
required_config: { cluster_name: 'test', account_id: '123456789012', ... },
expected_resources: {
'aws_vpc' => ['test-vpc'],
'aws_subnet' => ['test-public'],
'aws_iam_role' => ['test-node'],
},
expected_refs: [:vpc, :subnet, :iam],
required_tags: %w[ManagedBy Purpose Environment],
security_invariants: [
{ type: :no_wildcard_actions },
{ type: :no_public_ssh },
{ type: :encrypted_volumes },
],
)
puts generator.generate
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #generate ⇒ Object
- #generate_security ⇒ Object
- #generate_synthesis ⇒ Object
-
#initialize(**config) ⇒ ArchitectureSpecGenerator
constructor
A new instance of ArchitectureSpecGenerator.
Constructor Details
#initialize(**config) ⇒ ArchitectureSpecGenerator
Returns a new instance of ArchitectureSpecGenerator.
29 30 31 |
# File 'lib/pangea/testing/architecture_spec_generator.rb', line 29 def initialize(**config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
27 28 29 |
# File 'lib/pangea/testing/architecture_spec_generator.rb', line 27 def config @config end |
Instance Method Details
#generate ⇒ Object
33 34 35 |
# File 'lib/pangea/testing/architecture_spec_generator.rb', line 33 def generate [header, synthesis_spec, security_spec].compact.join("\n\n") end |
#generate_security ⇒ Object
41 42 43 |
# File 'lib/pangea/testing/architecture_spec_generator.rb', line 41 def generate_security [header, security_spec].join("\n") end |
#generate_synthesis ⇒ Object
37 38 39 |
# File 'lib/pangea/testing/architecture_spec_generator.rb', line 37 def generate_synthesis [header, synthesis_spec].join("\n") end |