Class: EcsDeployCli::DSL::Parser
- Inherits:
-
Object
- Object
- EcsDeployCli::DSL::Parser
- Defined in:
- lib/ecs_deploy_cli/dsl/parser.rb
Class Method Summary collapse
Instance Method Summary collapse
- #aws_profile_id(value) ⇒ Object
- #aws_region(value) ⇒ Object
- #cluster(name, &block) ⇒ Object
- #config ⇒ Object
- #container(container, extends: nil, &block) ⇒ Object
- #cron(name, &block) ⇒ Object
- #ensure_required_params! ⇒ Object
- #resolve ⇒ Object
- #service(name, &block) ⇒ Object
- #stage(stage) ⇒ Object
- #task(task, &block) ⇒ Object
Class Method Details
.load(file) ⇒ Object
68 69 70 71 72 73 |
# File 'lib/ecs_deploy_cli/dsl/parser.rb', line 68 def self.load(file) result = new result.instance_eval(File.read(file)) result.ensure_required_params! result end |
Instance Method Details
#aws_profile_id(value) ⇒ Object
6 7 8 |
# File 'lib/ecs_deploy_cli/dsl/parser.rb', line 6 def aws_profile_id(value) config[:aws_profile_id] = value end |
#aws_region(value) ⇒ Object
10 11 12 |
# File 'lib/ecs_deploy_cli/dsl/parser.rb', line 10 def aws_region(value) config[:aws_region] = value end |
#cluster(name, &block) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/ecs_deploy_cli/dsl/parser.rb', line 43 def cluster(name, &block) config[:cluster] = name @cluster ||= {}.with_indifferent_access @cluster = Cluster.new(name, config) @cluster.instance_exec(&block) if block end |
#config ⇒ Object
50 51 52 |
# File 'lib/ecs_deploy_cli/dsl/parser.rb', line 50 def config @config ||= {} end |
#container(container, extends: nil, &block) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/ecs_deploy_cli/dsl/parser.rb', line 18 def container(container, extends: nil, &block) @containers ||= {} @containers[container] = Container.new(container, config) @containers[container].merge(@containers[extends]) if extends @containers[container].instance_exec(&block) end |
#cron(name, &block) ⇒ Object
37 38 39 40 41 |
# File 'lib/ecs_deploy_cli/dsl/parser.rb', line 37 def cron(name, &block) @crons ||= {}.with_indifferent_access @crons[name] = Cron.new(name, config) @crons[name].instance_exec(&block) end |
#ensure_required_params! ⇒ Object
54 55 56 57 58 |
# File 'lib/ecs_deploy_cli/dsl/parser.rb', line 54 def ensure_required_params! [ :aws_profile_id, :aws_region, :cluster ].each { |key| raise "Missing required parameter #{key}" unless config[key] } end |
#resolve ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/ecs_deploy_cli/dsl/parser.rb', line 60 def resolve resolved_containers = (@containers || {}).transform_values(&:as_definition) resolved_tasks = (@tasks || {}).transform_values { |t| t.as_definition(resolved_containers) } resolved_crons = (@crons || {}).transform_values { |t| t.as_definition(resolved_tasks) } resolved_cluster = @cluster.as_definition [@services, resolved_tasks, resolved_crons, resolved_cluster] end |
#service(name, &block) ⇒ Object
31 32 33 34 35 |
# File 'lib/ecs_deploy_cli/dsl/parser.rb', line 31 def service(name, &block) @services ||= {}.with_indifferent_access @services[name.to_s] = Service.new(name, config) @services[name.to_s].instance_exec(&block) end |
#stage(stage) ⇒ Object
14 15 16 |
# File 'lib/ecs_deploy_cli/dsl/parser.rb', line 14 def stage(stage) config[:stage] = stage end |