Class: Chef::Knife::DigitalOceanSshkeyList
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::DigitalOceanSshkeyList
- Includes:
- DigitalOceanBase
- Defined in:
- lib/chef/knife/digital_ocean_sshkey_list.rb
Instance Method Summary collapse
Methods included from DigitalOceanBase
#client, #h, included, #locate_config_value, #validate!
Instance Method Details
#run ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/chef/knife/digital_ocean_sshkey_list.rb', line 22 def run $stdout.sync = true validate! sshkey_list = [ h.color('ID', :bold), h.color('Name', :bold), ] sshkeys = client.ssh_keys.list.ssh_keys sshkeys.sort! do |a, b| a.name <=> b.name end sshkeys.each do |sshkey| sshkey_list << sshkey.id.to_s sshkey_list << sshkey.name.to_s end puts h.list(sshkey_list, :uneven_columns_across, 2) end |