class Kontena::Cli::Grids::ListCommand
Public Instance Methods
execute()
click to toggle source
# File lib/kontena/cli/grids/list_command.rb, line 19 def execute if quiet? puts grids['grids'].map { |grid| grid['name'] }.join("\n") exit 0 end vputs gridlist = [] vspinner "Retrieving a list of available grids" do gridlist = grids['grids'].sort_by{|grid| grid['user_count']} end if gridlist.size == 0 self.verbose? && puts puts pastel.yellow("Kontena Master #{config.current_master.name} doesn't have any grids yet. Create one now using 'kontena grid create' command") self.verbose? && puts else vputs vputs "You have access to the following grids:" vputs if current_grid current_grid_entry = gridlist.find { |grid| grid['name'] == current_grid } current_grid_entry['name'] += pastel.yellow(' *') if current_grid_entry end print_table(gridlist) if self.use? vputs vspinner "* Selecting '#{gridlist.first['name']}' as the current grid" do config.current_master.grid = gridlist.first['name'] config.write end end end end
fields()
click to toggle source
# File lib/kontena/cli/grids/list_command.rb, line 15 def fields { name: 'name', nodes: 'node_count', services: 'service_count', users: 'user_count' } end