#!/usr/bin/env bash
# registry-gc
# description: run garbage collection on registry
# name: registry

set -eu

if ! sudo podman container exists registry; then
    echo "registry container does not exist"
    exit 1
fi

if sudo podman container exec -it registry bin/registry garbage-collect /etc/docker/registry/config.yml -m; then
    echo "Registry garbage collection ran successfully"
    exit 0
else
    echo "Error running registry garbage collection"
    exit 1
fi