lib/kontena/plugin/digital_ocean/nodes/terminate_command.rb in kontena-plugin-digitalocean-0.2.0.pre1 vs lib/kontena/plugin/digital_ocean/nodes/terminate_command.rb in kontena-plugin-digitalocean-0.2.0.pre2
- old
+ new
@@ -1,20 +1,28 @@
+require_relative '../prompts'
+
module Kontena::Plugin::DigitalOcean::Nodes
class TerminateCommand < Kontena::Command
include Kontena::Cli::Common
include Kontena::Cli::GridOptions
+ include Kontena::Plugin::DigitalOcean::Prompts
- parameter "NAME", "Node name"
- option "--token", "TOKEN", "DigitalOcean API token", required: true
+ parameter "[NAME]", "Node name"
+ option "--token", "TOKEN", "DigitalOcean API token", environment_variable: "DO_TOKEN"
+ option "--force", :flag, "Force remove", default: false, attribute_name: :forced
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 'kontena/machine/digital_ocean'
+ require_relative '../../../machine/digital_ocean'
grid = client(require_token).get("grids/#{current_grid}")
- destroyer = destroyer(client(require_token), token)
- destroyer.run!(grid, name)
+ destroyer = destroyer(client(token), do_token)
+ destroyer.run!(grid, node_name)
end
# @param [Kontena::Client] client
# @param [String] token
def destroyer(client, token)