Class: Shiprails::Ship::Config
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Shiprails::Ship::Config
- Includes:
- Thor::Actions
- Defined in:
- lib/shiprails/ship/config.rb
Instance Method Summary collapse
Instance Method Details
#done ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/shiprails/ship/config.rb', line 97 def done unless @version say "No config updates.", :green else say "Config update complete!", :green end end |
#update_ecs_services ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/shiprails/ship/config.rb', line 60 def update_ecs_services environment = args.second return unless @version say "Updating ECS services..." configuration[:services].each do |service_name, service| service[:regions].each do |region_name, region| ecs = Aws::ECS::Client.new(region: region_name.to_s) region[:environments].each do |environment_name| next unless environment == environment_name cluster_name = "#{project_name}_#{environment_name}" task_name = "#{project_name}_#{service_name}_#{environment_name}" begin task_definition_response = ecs.describe_task_definition({task_definition: task_name}) task_definition = task_definition_response.task_definition.to_hash rescue Aws::ECS::Errors::ClientException => e say "Missing ECS task for #{task_name}!", :red say "Run `ship setup`", :red exit end begin service_response = ecs.update_service({ cluster: cluster_name, service: service_name, task_definition: task_definition_response.task_definition.task_definition_arn }) say "Updated #{service_name} service." rescue Aws::ECS::Errors::ServiceNotFoundException, Aws::ECS::Errors::ServiceNotActiveException => e say "Missing ECS service for #{task_name}!", :red say "Run `ship setup`", :red exit end end end end say "ECS services updated.", :green end |
#update_ecs_tasks ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/shiprails/ship/config.rb', line 23 def update_ecs_tasks environment = args.second return unless @version say "Updating config version for ECS tasks..." configuration[:services].each do |service_name, service| service[:regions].each do |region_name, region| ecs = Aws::ECS::Client.new(region: region_name.to_s) region[:environments].each do |environment_name| next unless environment == environment_name cluster_name = "#{project_name}_#{environment_name}" task_name = "#{project_name}_#{service_name}_#{environment_name}" begin task_definition_description = ecs.describe_task_definition({task_definition: task_name}) task_definition = task_definition_description.task_definition.to_hash task_definition.delete :task_definition_arn task_definition.delete :revision task_definition.delete :status task_definition.delete :requires_attributes rescue Aws::ECS::Errors::ClientException => e say "Missing ECS task for #{task_name}!", :red say "Run `ship setup`", :red exit end task_definition[:container_definitions][0][:environment].map! do |e| if e[:name] == "S3_CONFIG_REVISION" e[:value] = "#{@version}" end e end task_definition_response = ecs.register_task_definition(task_definition) say "Updated #{task_name} task." end end end say "ECS tasks updated.", :green end |
#update_s3_config ⇒ Object
16 17 18 19 20 21 |
# File 'lib/shiprails/ship/config.rb', line 16 def update_s3_config command_string = args.join ' ' result = `S3_CONFIG_BUCKET=#{configuration[:config_s3_bucket]} bundle exec config #{command_string}` puts result @version = result.match(/New version: v([0-9]+)/)[1] rescue false end |