Sha256: 1291f956848a0f761b2817d05512320e0c2ad9ab3ca15537278340af311a005e

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

module Kontena::Plugin::Azure::Nodes
  class TerminateCommand < Kontena::Command
    include Kontena::Cli::Common
    include Kontena::Cli::GridOptions

    parameter "NAME", "Node name"
    option "--subscription-id", "SUBSCRIPTION ID", "Azure subscription id", required: true
    option "--subscription-cert", "CERTIFICATE", "Path to Azure management certificate", attribute_name: :certificate, required: true
    option "--force", :flag, "Force remove", default: false, attribute_name: :forced

    def execute
      require_api_url
      require_current_grid

      confirm_command(name) unless forced?

      require_relative '../../../machine/azure'

      grid = fetch_grid
      destroyer = destroyer(client(require_token), subscription_id, certificate)
      destroyer.run!(grid, name)
    end

    def fetch_grid
      client(require_token).get("grids/#{current_grid}")
    end

    # @param [Kontena::Client] client
    # @param [String] subscription_id
    # @param [String] certificate
    # @return [Kontena::Machine::Azure::NodeDestroyer]
    def destroyer(client, subscription_id, certificate)
      Kontena::Machine::Azure::NodeDestroyer.new(client, subscription_id, certificate)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kontena-plugin-azure-0.3.0 lib/kontena/plugin/azure/nodes/terminate_command.rb