Method: VMC::App::Delete#delete

Defined in:
lib/vmc/cli/app/delete.rb

#deleteObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/vmc/cli/app/delete.rb', line 18

def delete
  apps = client.apps

  if input[:all]
    return unless input[:really, "ALL APPS", :bad]

    to_delete = apps
    others = []
  else
    to_delete = input[:apps]
    others = apps - to_delete
  end

  all_services = apps.collect(&:services).flatten
  deleted_app_services = []

  spaced(to_delete) do |app|
    really = input[:all] || input[:really, app.name, :name]
    next unless really

    deleted_app_services += app.services

    with_progress("Deleting #{c(app.name, :name)}") do
      app.routes.collect(&:delete!) if input[:routes]
      app.delete!
    end
  end

  delete_orphaned_services(
    find_orphaned_services(deleted_app_services, all_services))

  to_delete
end