save checkpoint
This commit is contained in:
34
devops/scripts/scanner-artifact-boms-retention.sh
Normal file
34
devops/scripts/scanner-artifact-boms-retention.sh
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ -z "${PG_DSN:-}" ]]; then
|
||||
echo "PG_DSN is required (PostgreSQL connection string)." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
RETAIN_MONTHS="${1:-12}"
|
||||
DRY_RUN="${2:-true}"
|
||||
|
||||
if ! [[ "${RETAIN_MONTHS}" =~ ^[0-9]+$ ]]; then
|
||||
echo "retainMonths must be a positive integer." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "${RETAIN_MONTHS}" -lt 1 ]]; then
|
||||
echo "retainMonths must be >= 1." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "${DRY_RUN}" in
|
||||
true|false) ;;
|
||||
*)
|
||||
echo "dryRun must be 'true' or 'false'." >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
psql "${PG_DSN}" \
|
||||
--no-psqlrc \
|
||||
--set ON_ERROR_STOP=on \
|
||||
--quiet \
|
||||
--command "SELECT partition_name, dropped FROM scanner.drop_artifact_boms_partitions_older_than(${RETAIN_MONTHS}, ${DRY_RUN});"
|
||||
Reference in New Issue
Block a user