Sha256: 6848dbfd4a9b3753e04dfb264b1285326fce6b86da0b8572e915480b4dd56ce1

Contents?: true

Size: 913 Bytes

Versions: 28

Compression:

Stored size: 913 Bytes

Contents

require_relative 'services_helper'

module Kontena::Cli::Services
  class RemoveCommand < Kontena::Command
    include Kontena::Cli::Common
    include ServicesHelper

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

    def execute
      require_api_url
      token = require_token
      confirm_command(name) unless forced?

      spinner "Removing service #{name.colorize(:cyan)} " do
        client(token).delete("services/#{parse_service_id(name)}")
        removed = false
        until removed == true
          sleep 1
          begin
            client(token).get("services/#{parse_service_id(name)}")
          rescue Kontena::Errors::StandardError => exc
            if exc.status == 404
              removed = true
            else
              raise exc
            end
          end
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
kontena-cli-1.2.0.pre3 lib/kontena/cli/services/remove_command.rb
kontena-cli-1.2.0.pre2 lib/kontena/cli/services/remove_command.rb
kontena-cli-1.1.6 lib/kontena/cli/services/remove_command.rb
kontena-cli-1.2.0.pre1 lib/kontena/cli/services/remove_command.rb
kontena-cli-1.1.5 lib/kontena/cli/services/remove_command.rb
kontena-cli-1.1.5.rc3 lib/kontena/cli/services/remove_command.rb
kontena-cli-1.1.5.rc2 lib/kontena/cli/services/remove_command.rb
kontena-cli-1.1.5.rc1 lib/kontena/cli/services/remove_command.rb
kontena-cli-1.1.4 lib/kontena/cli/services/remove_command.rb
kontena-cli-1.2.0.dev1 lib/kontena/cli/services/remove_command.rb
kontena-cli-1.1.3 lib/kontena/cli/services/remove_command.rb
kontena-cli-1.1.2 lib/kontena/cli/services/remove_command.rb
kontena-cli-1.1.2.rc2 lib/kontena/cli/services/remove_command.rb
kontena-cli-1.1.2.rc1 lib/kontena/cli/services/remove_command.rb
kontena-cli-1.1.1 lib/kontena/cli/services/remove_command.rb
kontena-cli-1.1.1.rc1 lib/kontena/cli/services/remove_command.rb
kontena-cli-1.1.0 lib/kontena/cli/services/remove_command.rb
kontena-cli-1.1.0.rc2 lib/kontena/cli/services/remove_command.rb
kontena-cli-1.1.0.rc1 lib/kontena/cli/services/remove_command.rb
kontena-cli-1.1.0.pre1 lib/kontena/cli/services/remove_command.rb