Class: Kontena::Plugin::DigitalOcean::Nodes::TerminateCommand

Inherits:
Command
  • Object
show all
Includes:
Cli::Common, Cli::GridOptions, Prompts
Defined in:
lib/kontena/plugin/digital_ocean/nodes/terminate_command.rb

Instance Method Summary collapse

Methods included from Prompts

#ask_do_token, #ask_droplet_region, #ask_droplet_size, #ask_node

Instance Method Details

#destroyer(client, token) ⇒ Object

Parameters:

  • client (Kontena::Client)
  • token (String)


29
30
31
# File 'lib/kontena/plugin/digital_ocean/nodes/terminate_command.rb', line 29

def destroyer(client, token)
  Kontena::Machine::DigitalOcean::NodeDestroyer.new(client, token)
end

#executeObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/kontena/plugin/digital_ocean/nodes/terminate_command.rb', line 13

def execute
  require_api_url
  require_current_grid
  token = require_token
  node_name = ask_node(token)
  do_token = ask_do_token
  confirm_command(node_name) unless forced?

  require_relative '../../../machine/digital_ocean'
  grid = client(require_token).get("grids/#{current_grid}")
  destroyer = destroyer(client(token), do_token)
  destroyer.run!(grid, node_name)
end