Sha256: 9e900f3ca91d3f30f36657f71fd5c29fe25385c7d2b723de056e7d0368a7fb63

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 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
      suppress_warnings # until DO merges resource_kit pr #32
      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)
    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

1 entries across 1 versions & 1 rubygems

Version Path
kontena-plugin-digitalocean-0.3.1.rc1 lib/kontena/plugin/digital_ocean/nodes/terminate_command.rb