Sha256: e7429c971eb788b94d0fd00c25ac1c70d7e1b2cf6fe0104d47bd5710714bdc89

Contents?: true

Size: 1.06 KB

Versions: 77

Compression:

Stored size: 1.06 KB

Contents

require_relative 'common'

module Kontena::Cli::Stacks
  class RemoveCommand < Kontena::Command
    include Kontena::Cli::Common
    include Kontena::Cli::GridOptions
    include Common

    banner "Removes a stack in a grid on Kontena Master"

    parameter "NAME", "Stack name"
    option "--force", :flag, "Force remove", default: false, attribute_name: :forced

    requires_current_master
    requires_current_master_token

    def execute
      confirm_command(name) unless forced?
      spinner "Removing stack #{pastel.cyan(name)} " do
        remove_stack(name)
        wait_stack_removal(name)
      end
    end

    def remove_stack(name)
      client.delete("stacks/#{current_grid}/#{name}")
    end

    def wait_stack_removal(name)
      removed = false
      until removed == true
        begin
          client.get("stacks/#{current_grid}/#{name}")
          sleep 1
        rescue Kontena::Errors::StandardError => exc
          if exc.status == 404
            removed = true
          else
            raise exc
          end
        end
      end
    end
  end
end

Version data entries

77 entries across 77 versions & 1 rubygems

Version Path
kontena-cli-1.3.0.rc3 lib/kontena/cli/stacks/remove_command.rb
kontena-cli-1.3.0.rc2 lib/kontena/cli/stacks/remove_command.rb
kontena-cli-1.3.0.rc1 lib/kontena/cli/stacks/remove_command.rb
kontena-cli-1.3.0.pre2 lib/kontena/cli/stacks/remove_command.rb
kontena-cli-1.3.0.pre1 lib/kontena/cli/stacks/remove_command.rb
kontena-cli-1.2.2 lib/kontena/cli/stacks/remove_command.rb
kontena-cli-1.2.2.rc2 lib/kontena/cli/stacks/remove_command.rb
kontena-cli-1.2.2.rc1 lib/kontena/cli/stacks/remove_command.rb
kontena-cli-1.2.1 lib/kontena/cli/stacks/remove_command.rb
kontena-cli-1.2.1.rc1 lib/kontena/cli/stacks/remove_command.rb
kontena-cli-1.2.0 lib/kontena/cli/stacks/remove_command.rb
kontena-cli-1.2.0.rc3 lib/kontena/cli/stacks/remove_command.rb
kontena-cli-1.2.0.rc2 lib/kontena/cli/stacks/remove_command.rb
kontena-cli-1.2.0.rc1 lib/kontena/cli/stacks/remove_command.rb
kontena-cli-1.2.0.pre3 lib/kontena/cli/stacks/remove_command.rb
kontena-cli-1.2.0.pre2 lib/kontena/cli/stacks/remove_command.rb
kontena-cli-1.1.6 lib/kontena/cli/stacks/remove_command.rb
kontena-cli-1.2.0.pre1 lib/kontena/cli/stacks/remove_command.rb
kontena-cli-1.1.5 lib/kontena/cli/stacks/remove_command.rb
kontena-cli-1.1.5.rc3 lib/kontena/cli/stacks/remove_command.rb