Class: Chef::Knife::DigitalOceanSshkeyDestroy

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

Instance Method Summary collapse

Methods included from DigitalOceanBase

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

Instance Method Details

#runObject



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/chef/knife/digital_ocean_sshkey_destroy.rb', line 28

def run
  $stdout.sync = true

  validate!

  unless locate_config_value(:id)
    ui.error('SSH key id cannot be empty. => -i <id>')
    exit 1
  end

  result = client.ssh_keys.delete id: locate_config_value(:id)
  ui.info 'OK' if result == true || ui.error(JSON.parse(result)['message'])
end