Sha256: ead99351ff85fc32a3a767251efdd58336d51ea7f1724632f14550ff8b075246

Contents?: true

Size: 1.04 KB

Versions: 7

Compression:

Stored size: 1.04 KB

Contents

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", 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_relative '../../../machine/digital_ocean'
      grid = client(require_token).get("grids/#{current_grid}")
      destroyer = destroyer(client(token), do_token)
      destroyer.run!(grid, node_name)
    end

    # @param [Kontena::Client] client
    # @param [String] token
    def destroyer(client, token)
      Kontena::Machine::DigitalOcean::NodeDestroyer.new(client, token)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
kontena-plugin-digitalocean-0.2.5 lib/kontena/plugin/digital_ocean/nodes/terminate_command.rb
kontena-plugin-digitalocean-0.2.4 lib/kontena/plugin/digital_ocean/nodes/terminate_command.rb
kontena-plugin-digitalocean-0.2.3 lib/kontena/plugin/digital_ocean/nodes/terminate_command.rb
kontena-plugin-digitalocean-0.2.2 lib/kontena/plugin/digital_ocean/nodes/terminate_command.rb
kontena-plugin-digitalocean-0.2.1 lib/kontena/plugin/digital_ocean/nodes/terminate_command.rb
kontena-plugin-digitalocean-0.2.0 lib/kontena/plugin/digital_ocean/nodes/terminate_command.rb
kontena-plugin-digitalocean-0.2.0.pre2 lib/kontena/plugin/digital_ocean/nodes/terminate_command.rb