Skip to content

Commit

Permalink
Update delete-untagged-amazon-public-ecr-images.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
alessfg committed Feb 21, 2025
1 parent b29f834 commit df902c3
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ function batch_delete {
# otherwise any referenced untagged images can not be deleted.
IMAGE_DIGESTS=$(aws ecr-public describe-images \
--repository-name "${REPOSITORY_NAME}" \
--query 'imageDetails[?!imageTags && (contains(imageManifestMediaType, `manifest.list.v2`) || contains(imageManifestMediaType, `image.index.v1`)) && imagePushedAt < \`${CUTOFF_DATE}\`].{imageDigest: join(`=`, [`imageDigest`, imageDigest])}' \
--query "imageDetails[?!imageTags && (contains(imageManifestMediaType, `manifest.list.v2`) || contains(imageManifestMediaType, `image.index.v1`)) && imagePushedAt < '$CUTOFF_DATE'].{imageDigest: join(`=`, [`imageDigest`, imageDigest])}" \
--output text)

batch_delete "${IMAGE_DIGESTS}"

# Find untagged images and delete them.
IMAGE_DIGESTS=$(aws ecr-public describe-images \
--repository-name "${REPOSITORY_NAME}" \
--query 'imageDetails[?!imageTags && imagePushedAt < \`${CUTOFF_DATE}\`].{imageDigest: join(`=`, [`imageDigest`, imageDigest])}' \
--query "imageDetails[?!imageTags && imagePushedAt < '$CUTOFF_DATE'].{imageDigest: join(`=`, [`imageDigest`, imageDigest])}" \
--output text)

batch_delete "${IMAGE_DIGESTS}"
Expand Down

0 comments on commit df902c3

Please sign in to comment.