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.6.1 lib/kontena/cli/cloud/master/list_command.rb
krates-1.6.0 lib/kontena/cli/cloud/master/list_command.rb
kontena-cli-1.5.4 lib/kontena/cli/cloud/master/list_command.rb
kontena-cli-1.5.4.rc1 lib/kontena/cli/cloud/master/list_command.rb
kontena-cli-1.5.3 lib/kontena/cli/cloud/master/list_command.rb
kontena-cli-1.5.2 lib/kontena/cli/cloud/master/list_command.rb
kontena-cli-1.5.1 lib/kontena/cli/cloud/master/list_command.rb
kontena-cli-1.5.0 lib/kontena/cli/cloud/master/list_command.rb
kontena-cli-1.5.0.rc1 lib/kontena/cli/cloud/master/list_command.rb
kontena-cli-1.5.0.pre5 lib/kontena/cli/cloud/master/list_command.rb
kontena-cli-1.5.0.pre4 lib/kontena/cli/cloud/master/list_command.rb
kontena-cli-1.5.0.pre3 lib/kontena/cli/cloud/master/list_command.rb
kontena-cli-1.5.0.pre2 lib/kontena/cli/cloud/master/list_command.rb
kontena-cli-1.5.0.pre1 lib/kontena/cli/cloud/master/list_command.rb