Class: Kontena::Plugin::Cloud::Organization::ListCommand

Inherits:
Command
  • Object
show all
Includes:
Cli::Common, Cli::TableGenerator::Helper, Common
Defined in:
lib/kontena/plugin/cloud/organization/list_command.rb

Constant Summary

Constants included from CloudCommand

CloudCommand::PLATFORM_NOT_SELECTED_ERROR

Instance Method Summary collapse

Methods included from Common

#fetch_organizations, #prompt_organization

Methods included from CloudCommand

#verify_current_grid, #verify_current_master, #verify_current_master_token

Instance Method Details

#executeObject



9
10
11
12
13
14
15
16
17
# File 'lib/kontena/plugin/cloud/organization/list_command.rb', line 9

def execute
  organizations = fetch_organizations
  print_table(organizations.map{|o| o.api_data}) do |row|
    row.merge!(row['attributes'])
    row['name'] = row['name']
    row['account-status'] = row['account-status'] == 'active' ? pastel.green(row['account-status']) : row['account-status']
    row['role'] = row['owner'] ? pastel.cyan('owner') : 'member'
  end
end

#fieldsObject



19
20
21
22
23
24
25
# File 'lib/kontena/plugin/cloud/organization/list_command.rb', line 19

def fields
  {
    'name' => 'name',
    'account status' => 'account-status',
    'your role' => 'role'
  }
end