Class: Putpaws::Provision::ConfigWriter
- Inherits:
-
Object
- Object
- Putpaws::Provision::ConfigWriter
- Defined in:
- lib/putpaws/provision/config_writer.rb
Overview
Reflects provisioned resources into .putpaws/application.json and .putpaws/infra.json. Only the keys of the target service are touched. Shows a diff and asks for confirmation before writing.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#io ⇒ Object
readonly
Returns the value of attribute io.
-
#prompt ⇒ Object
readonly
Returns the value of attribute prompt.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #application_entry ⇒ Object
- #apply! ⇒ Object
-
#initialize(config:, state:, prompt:, io: $stdout) ⇒ ConfigWriter
constructor
A new instance of ConfigWriter.
- #network_entry ⇒ Object
- #target_entry ⇒ Object
Constructor Details
#initialize(config:, state:, prompt:, io: $stdout) ⇒ ConfigWriter
Returns a new instance of ConfigWriter.
13 14 15 16 17 18 |
# File 'lib/putpaws/provision/config_writer.rb', line 13 def initialize(config:, state:, prompt:, io: $stdout) @config = config @state = state @prompt = prompt @io = io end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
12 13 14 |
# File 'lib/putpaws/provision/config_writer.rb', line 12 def config @config end |
#io ⇒ Object (readonly)
Returns the value of attribute io.
12 13 14 |
# File 'lib/putpaws/provision/config_writer.rb', line 12 def io @io end |
#prompt ⇒ Object (readonly)
Returns the value of attribute prompt.
12 13 14 |
# File 'lib/putpaws/provision/config_writer.rb', line 12 def prompt @prompt end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
12 13 14 |
# File 'lib/putpaws/provision/config_writer.rb', line 12 def state @state end |
Instance Method Details
#application_entry ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/putpaws/provision/config_writer.rb', line 20 def application_entry { region: config.region, cluster: config.cluster_name, service: config.service_name, task_name_prefix: config.service_name, log_group_prefix: config.log_group, build_log_group_prefix: config.build_log_group, build_project_name_prefix: config.build_project_name, network: config.service_name, target: config.service_name, } end |
#apply! ⇒ Object
53 54 55 56 57 |
# File 'lib/putpaws/provision/config_writer.rb', line 53 def apply! write_key(path('application.json'), [config.service_name.to_sym], application_entry) write_key(path('infra.json'), [:network, config.service_name.to_sym], network_entry) write_key(path('infra.json'), [:target, config.service_name.to_sym], target_entry) end |
#network_entry ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/putpaws/provision/config_writer.rb', line 34 def network_entry { subnets: config.base[:subnets], security_groups: state.resources[:security_group_ids] || [], assign_public_ip: config.settings[:assign_public_ip] || 'DISABLED', } end |
#target_entry ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/putpaws/provision/config_writer.rb', line 42 def target_entry { # Used by EventBridge Scheduler (scheduler:deploy). scheduler_role: config.roles[:scheduler_role_arn], cluster: state.resources[:cluster_arn], # Revision-less on purpose: always run the latest ACTIVE revision. task_definition: config.service_task_definition_family, container_name: config.service_container_name, } end |