lib/command/cleanup_stale_apps.rb in cpl-0.4.1 vs lib/command/cleanup_stale_apps.rb in cpl-0.5.0
- old
+ new
@@ -8,24 +8,24 @@
OPTIONS = [
app_option(required: true),
skip_confirm_option
].freeze
DESCRIPTION = "Deletes the whole app (GVC with all workloads and all images) for all stale apps"
- LONG_DESCRIPTION = <<~HEREDOC
+ LONG_DESCRIPTION = <<~DESC
- Deletes the whole app (GVC with all workloads and all images) for all stale apps
- Stale apps are identified based on the creation date of the latest image
- Specify the amount of days after an app should be considered stale through `stale_app_image_deployed_days` in the `.controlplane/controlplane.yml` file
- If `match_if_app_name_starts_with` is `true` in the `.controlplane/controlplane.yml` file, it will delete all stale apps that start with the name
- Will ask for explicit user confirmation
- HEREDOC
+ DESC
def call # rubocop:disable Metrics/MethodLength
- return progress.puts "No stale apps found" if stale_apps.empty?
+ return progress.puts("No stale apps found.") if stale_apps.empty?
- progress.puts "Stale apps:"
+ progress.puts("Stale apps:")
stale_apps.each do |app|
- progress.puts " #{app[:name]} (#{Shell.color((app[:date]).to_s, :red)})"
+ progress.puts(" #{app[:name]} (#{Shell.color((app[:date]).to_s, :red)})")
end
return unless confirm_delete
progress.puts
@@ -72,17 +72,19 @@
Shell.confirm("\nAre you sure you want to delete these #{stale_apps.length} apps?")
end
def delete_gvc(app)
- cp.gvc_delete(app[:name])
- progress.puts "#{app[:name]} deleted"
+ step("Deleting app '#{app[:name]}'") do
+ cp.gvc_delete(app[:name])
+ end
end
def delete_images(app)
app[:images].each do |image|
- cp.image_delete(image)
- progress.puts "#{image} deleted"
+ step("Deleting image '#{image}'") do
+ cp.image_delete(image)
+ end
end
end
end
end