From da15d680a21860450753eff57b0e3157662eebe7 Mon Sep 17 00:00:00 2001 From: Stefan Reimer Date: Sun, 2 Oct 2022 20:54:42 +0200 Subject: [PATCH] feat: handle nothing to cleanup gracefully --- podman.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/podman.mk b/podman.mk index 626ad4f..7701967 100644 --- a/podman.mk +++ b/podman.mk @@ -38,7 +38,8 @@ clean: rm-test-image rm-image .PHONY: rm-remote-untagged rm-remote-untagged: @echo "Removing all untagged images from $(IMAGE) in $(REGION)" - @aws ecr-public batch-delete-image --repository-name $(IMAGE) --region $(REGION) --image-ids $$(for image in $$(aws ecr-public describe-images --repository-name $(IMAGE) --region $(REGION) --output json | jq -r '.imageDetails[] | select(.imageTags | not ).imageDigest'); do echo -n "imageDigest=$$image "; done) + @IMAGE_IDS=$$(for image in $$(aws ecr-public describe-images --repository-name $(IMAGE) --region $(REGION) --output json | jq -r '.imageDetails[] | select(.imageTags | not ).imageDigest'); do echo -n "imageDigest=$$image "; done) ; \ + [ -n "$$IMAGE_IDS" ] && aws ecr-public batch-delete-image --repository-name $(IMAGE) --region $(REGION) --image-ids $$IMAGE_IDS || echo "No image to remove" .PHONY: rm-image rm-image: