lib/kontena/cli/apps/deploy_command.rb in kontena-cli-0.9.3 vs lib/kontena/cli/apps/deploy_command.rb in kontena-cli-0.10.0

- old
+ new

@@ -36,17 +36,14 @@ end end def deploy_services(queue) queue.each do |service| - puts "deploying #{service['id'].colorize(:cyan)}" - data = {} - if service['deploy'] - data[:strategy] = service['deploy']['strategy'] if service['deploy']['strategy'] - data[:wait_for_port] = service['deploy']['wait_for_port'] if service['deploy']['wait_for_port'] - end - deploy_service(token, service['id'].split('/').last, data) + name = service['id'].split('/').last + short_name = name.sub("#{service_prefix}-", "") + puts "deploying #{short_name.colorize(:cyan)}" + deploy_service(token, name, {}) end end def create_or_update_service(name, options) # skip if service is already processed or it's not present @@ -55,11 +52,10 @@ # create/update linked services recursively before continuing unless options['links'].nil? parse_links(options['links']).each_with_index do |linked_service, index| # change prefixed service name also to links options options['links'][index] = "#{prefixed_name(linked_service[:name])}:#{linked_service[:alias]}" - create_or_update_service(linked_service[:name], services[linked_service[:name]]) unless in_deploy_queue?(linked_service[:name]) end end merge_external_links(options) @@ -69,32 +65,29 @@ service = update(name, options) else service = create(name, options) end - # add deploy options to service - service['deploy'] = options['deploy'] - deploy_queue.push service end def find_service_by_name(name) get_service(token, prefixed_name(name)) rescue nil end def create(name, options) - name = prefixed_name(name) puts "creating #{name.colorize(:cyan)}" + name = prefixed_name(name) data = {name: name} data.merge!(parse_data(options)) create_service(token, current_grid, data) end def update(id, options) + puts "updating #{id.colorize(:cyan)}" id = prefixed_name(id) data = parse_data(options) - puts "updating #{id.colorize(:cyan)}" update_service(token, id, data) end def in_deploy_queue?(name) deploy_queue.find {|service| service['name'] == prefixed_name(name)} != nil @@ -147,9 +140,20 @@ data[:cap_add] = options['cap_add'] if options['cap_add'] data[:cap_drop] = options['cap_drop'] if options['cap_drop'] data[:net] = options['net'] if options['net'] data[:log_driver] = options['log_driver'] if options['log_driver'] data[:log_opts] = options['log_opt'] if options['log_opt'] && !options['log_opt'].empty? + + deploy_opts = options['deploy'] || {} + data[:strategy] = deploy_opts['strategy'] if deploy_opts['strategy'] + deploy = {} + deploy[:wait_for_port] = deploy_opts['wait_for_port'] if deploy_opts.has_key?('wait_for_port') + deploy[:min_health] = deploy_opts['min_health'] if deploy_opts.has_key?('min_health') + unless deploy.empty? + data[:deploy_opts] = deploy + end + + data[:hooks] = options['hooks'] || {} data end end