Module: Ufo::Util
- Included in:
- Ecr::Cleaner, DSL::Helper, Docker::Builder, Docker::Cleaner, Docker::Pusher, Stack::Helper, Stack::Status, Task, Tasks::Register
- Defined in:
- lib/ufo/util.rb
Instance Method Summary collapse
-
#default_cluster(service) ⇒ Object
The default cluster normally defaults to the Ufo.env value.
- #display_params(options) ⇒ Object
- #execute(command, local_options = {}) ⇒ Object
- #pretty_time(total_seconds) ⇒ Object
-
#settings ⇒ Object
Keys are strings for simplicity.
- #task_definition_arns(service, max_items = 10) ⇒ Object
-
#user_params ⇒ Object
Custom user params from .ufo/params.yml Param keys are symbols for the aws-sdk calls.
Instance Method Details
#default_cluster(service) ⇒ Object
The default cluster normally defaults to the Ufo.env value. But it can be overriden by ufo/settings.yml cluster
More info: ufoships.com/docs/settings/
9 10 11 12 13 14 |
# File 'lib/ufo/util.rb', line 9 def default_cluster(service) # to_s.to_sym in case service is nil settings.dig(:service_cluster, service.to_s.to_sym) || settings[:cluster] || Ufo.env end |
#display_params(options) ⇒ Object
52 53 54 |
# File 'lib/ufo/util.rb', line 52 def display_params() puts YAML.dump(.deep_stringify_keys) end |
#execute(command, local_options = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ufo/util.rb', line 27 def execute(command, ={}) if @options[:noop] && ![:live] say "NOOP: #{command}" result = true # always success with no noop for specs else if [:use_system] result = system(command) else result = `#{command}` end end result end |
#pretty_time(total_seconds) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/ufo/util.rb', line 42 def pretty_time(total_seconds) minutes = (total_seconds / 60) % 60 seconds = total_seconds % 60 if total_seconds < 60 "#{seconds.to_i}s" else "#{minutes.to_i}m #{seconds.to_i}s" end end |
#settings ⇒ Object
Keys are strings for simplicity.
17 18 19 |
# File 'lib/ufo/util.rb', line 17 def settings @settings ||= Ufo.settings end |
#task_definition_arns(service, max_items = 10) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/ufo/util.rb', line 56 def task_definition_arns(service, max_items=10) resp = ecs.list_task_definitions( family_prefix: service, sort: "DESC", ) arns = resp.task_definition_arns arns = arns.select do |arn| task_definition = arn.split('/').last.split(':').first task_definition == service end arns[0..max_items] end |