module Kontena::Plugin::Upcloud::Prompts::NodeName::Defaults
Public Instance Methods
default_name()
click to toggle source
# File lib/kontena/plugin/upcloud/prompts.rb, line 42 def default_name nodes = client.get("grids/#{current_grid}/nodes") nodes = nodes['nodes'].select{ |n| n['labels'] && n['labels'].include?('provider=upcloud'.freeze) } raise "Did not find any nodes with label provider=upcloud" if nodes.empty? prompt.select("Select node:") do |menu| nodes.sort_by{|n| n['node_number'] }.reverse.each do |node| initial = node['initial_member'] ? '(initial) ' : '' menu.choice "#{node['name']} #{initial}", node['name'] end end end