Class: Dockerun::Cli::DeleteContainer

Inherits:
Object
  • Object
show all
Defined in:
lib/dockerun/cli/delete_container.rb

Instance Method Summary collapse

Constructor Details

#initializeDeleteContainer

Returns a new instance of DeleteContainer.



12
13
14
# File 'lib/dockerun/cli/delete_container.rb', line 12

def initialize
  @proxy = DSLProxy.new
end

Instance Method Details

#cfObject



50
51
52
53
54
55
# File 'lib/dockerun/cli/delete_container.rb', line 50

def cf
  if @_cf.nil?
    @_cf = CommandFactory.new
  end
  @_cf
end

#delete_containerObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/dockerun/cli/delete_container.rb', line 26

def delete_container
  selSpec = CliEngine.select_spec(@proxy.exec_root)
  cont = File.read(selSpec)
  @proxy.set_dry_run_mode
  @proxy.instance_eval(cont)

  skip = pmt.no?(" Delete container named '#{@proxy.container_name}'?")
  if not skip
    cf.stop_container(@proxy.container_name).run
    res = cf.delete_container(@proxy.container_name).run
    if res.success?
      pmt.puts " Container '#{@proxy.container_name}' deleted".green
    else
      pmt.puts " Container '#{@proxy.container_name}' deletion failed. Error was : #{res.err_lines.join("\n")}".red
    end
  else
    pmt.puts " Container deletion of name '#{@proxy.container_name}' aborted.".yellow
  end
end

#pmtObject



46
47
48
# File 'lib/dockerun/cli/delete_container.rb', line 46

def pmt
  CliEngine.pmt
end

#start(root) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/dockerun/cli/delete_container.rb', line 16

def start(root)
  @proxy.set_exec_root(root)
  begin
    pmt.puts " Dockerun version #{Dockerun::VERSION}".yellow
    pmt.puts " Operational : Delete Container"
    delete_container
  rescue TTY::Reader::InputInterrupt
  end
end