Class: ECSHelper::Command::Deploy
- Defined in:
- lib/ecs_helper/command/deploy.rb
Constant Summary collapse
- DEFAULT_TIMEOUT =
300
- STEP =
5
Instance Attribute Summary collapse
-
#new_task_definition ⇒ Object
Returns the value of attribute new_task_definition.
-
#repositories ⇒ Object
Returns the value of attribute repositories.
-
#service ⇒ Object
writeonly
Sets the attribute service.
-
#task_definition ⇒ Object
Returns the value of attribute task_definition.
Attributes inherited from Base
#client, #helper, #option_parser, #options, #type
Instance Method Summary collapse
- #cmd_option_parser ⇒ Object
- #run ⇒ Object
- #update_service(task_definition_arn) ⇒ Object
- #wait_for_deployment(time = 0) ⇒ Object
Methods inherited from Base
#application, #check_bin, #initialize, #printable?, #project, #required, #validate
Methods included from Logging
Constructor Details
This class inherits a constructor from ECSHelper::Command::Base
Instance Attribute Details
#new_task_definition ⇒ Object
Returns the value of attribute new_task_definition.
4 5 6 |
# File 'lib/ecs_helper/command/deploy.rb', line 4 def new_task_definition @new_task_definition end |
#repositories ⇒ Object
Returns the value of attribute repositories.
4 5 6 |
# File 'lib/ecs_helper/command/deploy.rb', line 4 def repositories @repositories end |
#service=(value) ⇒ Object
Sets the attribute service
4 5 6 |
# File 'lib/ecs_helper/command/deploy.rb', line 4 def service=(value) @service = value end |
#task_definition ⇒ Object
Returns the value of attribute task_definition.
4 5 6 |
# File 'lib/ecs_helper/command/deploy.rb', line 4 def task_definition @task_definition end |
Instance Method Details
#cmd_option_parser ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ecs_helper/command/deploy.rb', line 8 def cmd_option_parser = {} parser = ::OptionParser.new do |opts| opts. = "Usage: ecs_helper deploy [options]" opts.on("-p VALUE", "--project VALUE", "Set project name, if not specified will look at ENV['PROJECT'], will be used to detect cluster") { |p| [:project] = processEqual(p) } opts.on("-a VALUE", "--application VALUE", "Set application name, if not specified will look at ENV['APPLICATION'], will be used to detect service and task definition") { |a| [:application] = processEqual(a) } opts.on("-e VALUE", "--environment VALUE", "Set environment, if not specified will look at ENV['ENVIRONMENT'], it there is empty will try to detect based on the branch") { |e| [:environment] = processEqual(e) } opts.on("-v VALUE", "--version VALUE", "Set version which will be applied to all containers in the task if tag is present in the repo") { |t| [:version] = processEqual(t) } opts.on("-cl VALUE", "--cluster VALUE", "Set cluster name, could be autodetected if project and environment are specified") { |c| [:cluster] = processEqual(c) } opts.on("-s VALUE", "--service VALUE", "Set service, could be autodetected if application and environment are specified") { |s| [:service] = processEqual(s) } opts.on("-t VALUE", "--timeout VALUE", "Set timeout how long to wait until deployment finished") { |t| [:timeout] = processEqual(t) } end [parser, ] end |
#run ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ecs_helper/command/deploy.rb', line 23 def run task_definition_helper = ECSHelper::TaskDefinitionHelper.new(helper, service) service_task_definition = task_definition_helper.service_task_definition new_task_definition_hash = task_definition_helper.new_task_definition_hash new_task_definition = task_definition_helper.register_task_definition(new_task_definition_hash) log("Command", type) log("Options", ) log("Environment", environment) log("Cluster", cluster_arn) log("Service", service_arn) log("Version", version) log("Service task definition", service_task_definition.task_definition_arn) log("Containers", task_definition_helper.pretty_container_definitions) log("New task definition", new_task_definition.task_definition_arn) update_service(new_task_definition.task_definition_arn) && log("Update service", "Service task definition was updated") log("Waiting for deployment...") wait_for_deployment && log("Success", "Application was succesfully deployed", :cyan) end |
#update_service(task_definition_arn) ⇒ Object
42 43 44 |
# File 'lib/ecs_helper/command/deploy.rb', line 42 def update_service(task_definition_arn) helper.update_service(cluster_arn, service_arn, task_definition_arn) end |