Class: VMC::Service::Delete

Inherits:
Base
  • Object
show all
Defined in:
lib/vmc/cli/service/delete.rb

Instance Method Summary collapse

Methods inherited from CLI

#check_logged_in, #check_target, #client, client, client=, #client_target, #color_enabled?, #default_action, #ensure_config_dir, #err, #execute, #fail, #force?, #invalidate_client, #log_error, #name_list, #no_v2, #one_of, #precondition, #quiet?, #remove_target_info, #sane_target_url, #save_target_info, #save_targets, #set_target, #table, #target_file, #target_info, #targets_info, #tokens_file, #user_colors, #v2?, #verbose?

Methods included from VMC::Spacing

#indented, #justify, #line, #lines, #quiet?, #spaced, #start_line, #tabular, #text_width, #trim_escapes

Methods included from Interactive

#ask, #handler, #input_state, #list_choices, #prompt, #show_default

Instance Method Details

#delete_serviceObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/vmc/cli/service/delete.rb', line 30

def delete_service
  if input[:all]
    return unless input[:really, "ALL SERVICES", :bad]

    client.service_instances.each do |i|
      invoke :delete_service, :instance => i, :really => true
    end

    return
  end

  instance = input[:instance]

  return unless input[:really, instance.name, :name]

  bindings = []

  if v2?
    bindings = instance.service_bindings

    unless bindings.empty? || !input[:unbind, bindings.collect(&:app)]
      bindings.each do |b|
        invoke :unbind_service, :instance => instance, :app => b.app
      end

      bindings = []
    end
  end

  with_progress("Deleting #{c(instance.name, :name)}") do |s|
    if bindings.empty?
      instance.delete!
    else
      s.skip do
        apps = bindings.collect(&:app).collect { |a| b(a.name) }
        err "Service instance is bound to #{human_list(apps)}."
      end
    end
  end
end