Sha256: 9eb460d08df7a86c3cf7af4099506f3df4782c20321440b19bfcb1149b8f1e89

Contents?: true

Size: 932 Bytes

Versions: 34

Compression:

Stored size: 932 Bytes

Contents

module Kontena::Cli::Cloud::Master
  class ListCommand < Kontena::Command

    include Kontena::Cli::Common
    include Kontena::Cli::TableGenerator::Helper

    callback_matcher 'cloud-master', 'list'

    option '--return', :flag, 'Return the list', hidden: true

    requires_current_account_token

    def fields
      quiet? ? ['id'] : %w(id name owner url connected)
    end

    def execute
      response = spin_if(!quiet?, "Retrieving Master list from Kontena Cloud") do
        cloud_client.get('user/masters')
      end

      unless response && response.kind_of?(Hash) && response['data'].kind_of?(Array)
        abort pastel.red("Listing masters failed")
      end

      return Array(response['data']) if self.return?

      print_table(response['data']) do |row|
        row.merge!(row['attributes'])
        row['connected'] = !!row['connected'] ? pastel.green('yes') : pastel.red('no')
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
krates-1.7.11 lib/kontena/cli/cloud/master/list_command.rb
krates-1.7.10 lib/kontena/cli/cloud/master/list_command.rb
krates-1.7.9 lib/kontena/cli/cloud/master/list_command.rb
krates-1.7.8 lib/kontena/cli/cloud/master/list_command.rb
krates-1.7.7 lib/kontena/cli/cloud/master/list_command.rb
krates-1.7.6 lib/kontena/cli/cloud/master/list_command.rb
krates-1.7.5 lib/kontena/cli/cloud/master/list_command.rb
krates-1.7.4 lib/kontena/cli/cloud/master/list_command.rb
krates-1.7.3 lib/kontena/cli/cloud/master/list_command.rb
krates-1.7.2 lib/kontena/cli/cloud/master/list_command.rb
krates-1.7.1 lib/kontena/cli/cloud/master/list_command.rb
krates-1.7.0 lib/kontena/cli/cloud/master/list_command.rb
krates-1.6.9 lib/kontena/cli/cloud/master/list_command.rb
krates-1.6.8 lib/kontena/cli/cloud/master/list_command.rb
krates-1.6.7 lib/kontena/cli/cloud/master/list_command.rb
krates-1.6.6 lib/kontena/cli/cloud/master/list_command.rb
krates-1.6.5 lib/kontena/cli/cloud/master/list_command.rb
krates-1.6.4 lib/kontena/cli/cloud/master/list_command.rb
krates-1.6.3 lib/kontena/cli/cloud/master/list_command.rb
krates-1.6.2 lib/kontena/cli/cloud/master/list_command.rb