Class: Chef::Knife::DigitalOceanSshkeyList

Inherits:
Chef::Knife
  • Object
show all
Includes:
DigitalOceanBase
Defined in:
lib/chef/knife/digital_ocean_sshkey_list.rb

Instance Method Summary collapse

Methods included from DigitalOceanBase

#client, included, load_deps, #locate_config_value, #validate!, #wait_for_status

Instance Method Details

#runObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/chef/knife/digital_ocean_sshkey_list.rb', line 22

def run
  $stdout.sync = true

  validate!

  sshkey_list = [
    ui.color('ID',   :bold),
    ui.color('Name', :bold),
    ui.color('Fingerprint', :bold)
  ]

  sshkeys = client.ssh_keys.all

  sshkeys.sort_by(&:name).each do |sshkey|
    sshkey_list << sshkey.id.to_s
    sshkey_list << sshkey.name.to_s
    sshkey_list << sshkey.fingerprint.to_s
  end

  puts ui.list(sshkey_list, :uneven_columns_across, 3)
end