From 5c93642f2a3382507c0c94fb58ee5b315b3fe62c Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 15 Feb 2023 20:33:57 +0100 Subject: [PATCH] Prepare for custom pruning --- lib/mrsk/commands/prune.rb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/mrsk/commands/prune.rb b/lib/mrsk/commands/prune.rb index 0a0902b2..71218cda 100644 --- a/lib/mrsk/commands/prune.rb +++ b/lib/mrsk/commands/prune.rb @@ -2,14 +2,11 @@ require "active_support/duration" require "active_support/core_ext/numeric/time" class Mrsk::Commands::Prune < Mrsk::Commands::Base - PRUNE_IMAGES_AFTER = 7.days.in_hours.to_i - PRUNE_CONTAINERS_AFTER = 3.days.in_hours.to_i - - def images - docker :image, :prune, "--all", "--force", "--filter", "label=service=#{config.service}", "--filter", "until=#{PRUNE_IMAGES_AFTER}h" + def images(until_hours: 7.days.in_hours.to_i) + docker :image, :prune, "--all", "--force", "--filter", "label=service=#{config.service}", "--filter", "until=#{until_hours}h" end - def containers - docker :container, :prune, "--force", "--filter", "label=service=#{config.service}", "--filter", "until=#{PRUNE_CONTAINERS_AFTER}h" + def containers(until_hours: 3.days.in_hours.to_i) + docker :container, :prune, "--force", "--filter", "label=service=#{config.service}", "--filter", "until=#{until_hours}h" end end