Sha256: f7599e1b5f6a47953b00af0ad1d260c87865cf0933fe100ae717cc532e44c064

Contents?: true

Size: 814 Bytes

Versions: 5

Compression:

Stored size: 814 Bytes

Contents

require_relative 'common'

module Kontena::Cli::Grids
  class RemoveCommand < Kontena::Command
    include Kontena::Cli::Common
    include Common

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

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

      if !grid.nil?
        response = client(token).delete("grids/#{grid['id']}")
        if response
          clear_current_grid if grid['id'] == current_grid
          puts "removed #{pastel.cyan(grid['name'])}"
        end
      else
        abort "Could not resolve grid by name [#{name}]. For a list of existing grids please run: kontena grid list".colorize(:red)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
kontena-cli-0.16.0.pre5 lib/kontena/cli/grids/remove_command.rb
kontena-cli-0.16.0.pre4 lib/kontena/cli/grids/remove_command.rb
kontena-cli-0.16.0.pre3 lib/kontena/cli/grids/remove_command.rb
kontena-cli-0.16.0.pre2 lib/kontena/cli/grids/remove_command.rb
kontena-cli-0.16.0.pre1 lib/kontena/cli/grids/remove_command.rb