Class: Kontena::Plugin::Cloud::Image::ListCommand

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

Constant Summary

Constants included from CloudCommand

CloudCommand::PLATFORM_NOT_SELECTED_ERROR

Instance Method Summary collapse

Methods included from Common

#default_org, #image_distribution_url, #image_registry_client, #image_registry_url

Methods included from CloudCommand

#verify_current_grid, #verify_current_master, #verify_current_master_token

Instance Method Details

#executeObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/kontena/plugin/cloud/image/list_command.rb', line 13

def execute

  org = self.organization || default_org

  repos = image_registry_client.get("/organizations/#{org}/repositories")['data']
  print_table(repos) do |r|
    r['pulls'] = r.dig('attributes', 'pulls')
    r['created_at'] = time_ago( Time.parse(r.dig('attributes', 'created-at')).to_i )
    r['public'] = r.dig('attributes', 'public')
  end
end

#fieldsObject



25
26
27
28
29
30
31
32
# File 'lib/kontena/plugin/cloud/image/list_command.rb', line 25

def fields
  {
    'name' => 'id',
    'pulls' => 'pulls',
    'public' => 'public',
    'created' => 'created_at'
  }
end