Class: Dash::Cli::Prune

Inherits:
Base
  • Object
show all
Defined in:
lib/dash/cli/prune.rb

Constant Summary

Constants inherited from Base

Base::AUTOMATIC_DEPLOY_LOCK_MESSAGE, Base::HOOK_MUTEX, Base::VERBOSITY

Instance Method Summary collapse

Methods inherited from Base

dynamic_command_class, exit_on_failure?, #initialize

Constructor Details

This class inherits a constructor from Dash::Cli::Base

Instance Method Details

#all ⇒ Object



3
4
5
6
7
8
# File 'lib/dash/cli/prune.rb', line 3

def all
  modify(lock: true, server_lock: true) do
    containers
    images
  end
end

#containers ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dash/cli/prune.rb', line 21

def containers
  retain = options.fetch(:retain, DASH.config.retain_containers)
  raise "retain must be at least 1" if retain < 1

  modify(lock: true, server_lock: true) do
    on(DASH.hosts) do |host|
      # One round trip per host, whatever it runs: a host with no app roles still
      # records that the sweep reached it.
      execute *DASH.auditor.record_then("Pruned containers",
        *DASH.roles_on(host).map { |role| DASH.prune.app_containers(retain: retain, role: role) })
    end
  end
end

#images ⇒ Object



11
12
13
14
15
16
17
# File 'lib/dash/cli/prune.rb', line 11

def images
  modify(lock: true, server_lock: true) do
    on(DASH.hosts) do
      execute *DASH.auditor.record_then("Pruned images", DASH.prune.dangling_images, DASH.prune.tagged_images)
    end
  end
end