Class: Ufo::Tasks::Register
- Inherits:
-
Object
- Object
- Ufo::Tasks::Register
- Includes:
- AwsService, Util
- Defined in:
- lib/ufo/tasks/register.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#fix_log_configuation_option(data) ⇒ Object
LogConfiguration requires a string with dashes as the keys docs.aws.amazon.com/sdkforruby/api/Aws/ECS/Client.html.
-
#initialize(template_definition_path, options = {}) ⇒ Register
constructor
A new instance of Register.
-
#register ⇒ Object
aws ecs register-task-definition –cli-input-json file://.ufo/output/hi-web-prod.json.
- #register_task_definition(data) ⇒ Object
Methods included from AwsService
#cloudwatchlogs, #ecr, #ecs, #elb
Methods included from Util
#default_cluster, #default_params, #display_params, #execute, #pretty_time, #settings
Constructor Details
#initialize(template_definition_path, options = {}) ⇒ Register
Returns a new instance of Register.
18 19 20 21 |
# File 'lib/ufo/tasks/register.rb', line 18 def initialize(template_definition_path, ={}) @template_definition_path = template_definition_path @options = end |
Class Method Details
.register(task_name, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/ufo/tasks/register.rb', line 9 def self.register(task_name, ={}) Dir.glob("#{Ufo.root}/.ufo/output/*").each do |path| if task_name == :all or path.include?(task_name) task_register = Tasks::Register.new(path, ) task_register.register end end end |
Instance Method Details
#fix_log_configuation_option(data) ⇒ Object
LogConfiguration requires a string with dashes as the keys docs.aws.amazon.com/sdkforruby/api/Aws/ECS/Client.html
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ufo/tasks/register.rb', line 58 def fix_log_configuation_option(data) definitions = data[:container_definitions] definitions.each do |definition| next unless definition[:log_configuration] = definition[:log_configuration][:options] ["awslogs-group"] = .delete(:awslogs_group) ["awslogs-region"] = .delete(:awslogs_region) ["awslogs-stream-prefix"] = .delete(:awslogs_stream_prefix) end data end |
#register ⇒ Object
aws ecs register-task-definition –cli-input-json file://.ufo/output/hi-web-prod.json
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ufo/tasks/register.rb', line 24 def register data = JSON.parse(IO.read(@template_definition_path), symbolize_names: true) data = data.to_snake_keys data = fix_log_configuation_option(data) = "#{data[:family]} task definition registered." if @options[:noop] = "NOOP: #{}" else register_task_definition(data) end puts unless @options[:mute] end |
#register_task_definition(data) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ufo/tasks/register.rb', line 37 def register_task_definition(data) if ENV["UFO_SHOW_REGISTER_TASK_DEFINITION"] puts "Registering task definition with:" display_params(data) end ecs.register_task_definition(data) rescue Aws::ECS::Errors::ClientException => e if e. =~ /No Fargate configuration exists for given values/ puts "ERROR: #{e.}".colorize(:red) puts "Configured values are: cpu #{data[:cpu]} memory #{data[:memory]}" puts "Check that the cpu and memory values are a supported combination by Fargate." puts "More info: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html" exit 1 else raise end end |