From a9adb834e569b7b8e5485574b9b9dadd63ccb6af Mon Sep 17 00:00:00 2001 From: Pallav Vasa Date: Sat, 17 May 2025 08:08:15 +0000 Subject: [PATCH] feat: move image cleanup function inside gitops router --- .bin/clean_dangling_images.sh | 12 ------------ gitops_router.sh | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 16 deletions(-) delete mode 100755 .bin/clean_dangling_images.sh diff --git a/.bin/clean_dangling_images.sh b/.bin/clean_dangling_images.sh deleted file mode 100755 index 96a9f8c..0000000 --- a/.bin/clean_dangling_images.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -# Get list of image IDs with tag (dangling images) -dangling_images=$(podman images -f "dangling=true" -q) - -if [ -z "$dangling_images" ]; then - echo "✅ No dangling images to remove." -else - echo "⚠️ Removing dangling images..." - echo "$dangling_images" | xargs podman rmi -f - echo "🧹 Done!" -fi diff --git a/gitops_router.sh b/gitops_router.sh index 7c05a25..850d38c 100644 --- a/gitops_router.sh +++ b/gitops_router.sh @@ -42,6 +42,19 @@ function update() { chmod "$3" "$output_path" } +clean_images() { + # Get list of image IDs with tag (dangling images) + dangling_images=$(podman images -f "dangling=true" -q) + + if [ -z "$dangling_images" ]; then + echo "✅ No dangling images to remove." + else + echo "⚠️ Removing dangling images..." + echo "$dangling_images" | xargs podman rmi + echo "🧹 Done!" + fi +} + # Strip arguments and parse command read -r command args <<<"$SSH_ORIGINAL_COMMAND" @@ -77,9 +90,6 @@ update) gitops_router) update gitops_router.sh .local/bin 500 ;; - clean_dangling_images) - update .bin/clean_dangling_images.sh .local/bin 500 - ;; home_tar) update home.tar.gz . 500 media ;; @@ -89,7 +99,7 @@ update) esac ;; clean) - "$HOME"/.local/bin/clean_dangling_images.sh + clean_images ;; status) podman images