module Ufo::Util
Public Instance Methods
default_cluster(service)
click to toggle source
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/
# 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)
click to toggle source
# File lib/ufo/util.rb, line 52 def display_params(options) puts YAML.dump(options.deep_stringify_keys) end
execute(command, local_options={})
click to toggle source
# File lib/ufo/util.rb, line 27 def execute(command, local_options={}) if @options[:noop] && !local_options[:live] say "NOOP: #{command}" result = true # always success with no noop for specs else if local_options[:use_system] result = system(command) else result = `#{command}` end end result end
pretty_time(total_seconds)
click to toggle source
# 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()
click to toggle source
Keys are strings for simplicity.
# File lib/ufo/util.rb, line 17 def settings @settings ||= Ufo.settings end
task_definition_arns(service, max_items=10)
click to toggle source
# 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
user_params()
click to toggle source
Custom user params from .ufo/params.yml Param
keys are symbols for the aws-sdk calls.
# File lib/ufo/util.rb, line 23 def user_params @user_params ||= Param.new.data end