class Kontena::Cli::Grids::RemoveCommand

Public Instance Methods

execute() click to toggle source
# File lib/kontena/cli/grids/remove_command.rb, line 11
def execute
  require_api_url
  token = require_token
  name_list.each do |name|
    confirm_command(name) unless forced?
    grid = find_grid_by_name(name)

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