Sha256: b765e14e12b3b3869802aa551dae2def168f02170e1c4fa9ab2eec506f87b989

Contents?: true

Size: 1.14 KB

Versions: 10

Compression:

Stored size: 1.14 KB

Contents

require 'kontena/plugin/digital_ocean/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
      suppress_warnings # until DO merges resource_kit pr #32
      require 'kontena/machine/digital_ocean'
      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?

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

10 entries across 10 versions & 3 rubygems

Version Path
krates-plugin-digitalocean-0.3.11 lib/kontena/plugin/digital_ocean/nodes/terminate_command.rb
krates-plugin-digitalocean-0.3.10 lib/kontena/plugin/digital_ocean/nodes/terminate_command.rb
krates-plugin-digitalocean-0.3.9 lib/kontena/plugin/digital_ocean/nodes/terminate_command.rb
krates-plugin-digitalocean-0.3.8 lib/kontena/plugin/digital_ocean/nodes/terminate_command.rb
staticpages-plugin-digitalocean-0.3.7 lib/kontena/plugin/digital_ocean/nodes/terminate_command.rb
staticpages-plugin-digitalocean-0.3.6 lib/kontena/plugin/digital_ocean/nodes/terminate_command.rb
staticpages-plugin-digitalocean-0.3.5 lib/kontena/plugin/digital_ocean/nodes/terminate_command.rb
kontena-plugin-digitalocean-0.3.3 lib/kontena/plugin/digital_ocean/nodes/terminate_command.rb
kontena-plugin-digitalocean-0.3.2 lib/kontena/plugin/digital_ocean/nodes/terminate_command.rb
kontena-plugin-digitalocean-0.3.1 lib/kontena/plugin/digital_ocean/nodes/terminate_command.rb