mirror of
https://github.com/falcosecurity/falco.git
synced 2025-06-28 15:47:25 +00:00
build(.circleci): script for automatic cleanup of Falco development releases
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
This commit is contained in:
parent
d25e07381e
commit
2880bb1f23
58
.circleci/cleanup
Executable file
58
.circleci/cleanup
Executable file
@ -0,0 +1,58 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "usage: $0 -p 0987654321 -r <deb-dev|rpm-dev|bin-dev>"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
user=poiana
|
||||||
|
|
||||||
|
# Get the versions to delete.
|
||||||
|
#
|
||||||
|
# $1: repository to lookup
|
||||||
|
# $2: number of versions to skip.
|
||||||
|
get_versions() {
|
||||||
|
# The API endpoint returns the Falco package versions sort by most recent.
|
||||||
|
IFS=$'\n' read -r -d '' -a all < <(curl -s --header "Content-Type: application/json" "https://api.bintray.com/packages/falcosecurity/$1/falco" | jq -r '.versions | .[]' | tail -n "+$2")
|
||||||
|
}
|
||||||
|
|
||||||
|
rem_versions() {
|
||||||
|
for i in "${!all[@]}";
|
||||||
|
do
|
||||||
|
JFROG_CLI_LOG_LEVEL=DEBUG jfrog bt vd --quiet --user "${user}" --key "${pass}" "falcosecurity/$1/falco/${all[$i]}"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
while getopts ":p::r:" opt; do
|
||||||
|
case "${opt}" in
|
||||||
|
p )
|
||||||
|
pass=${OPTARG}
|
||||||
|
;;
|
||||||
|
r )
|
||||||
|
repo="${OPTARG}"
|
||||||
|
[[ "${repo}" == "deb-dev" || "${repo}" == "rpm-dev" || "${repo}" == "bin-dev" ]] || usage
|
||||||
|
;;
|
||||||
|
: )
|
||||||
|
echo "invalid option: ${OPTARG} requires an argument" 1>&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
\?)
|
||||||
|
echo "invalid option: ${OPTARG}" 1>&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((OPTIND-1))
|
||||||
|
|
||||||
|
if [ -z "${pass}" ] || [ -z "${repo}" ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
skip=51
|
||||||
|
if [[ "${repo}" == "bin-dev" ]]; then
|
||||||
|
skip=11
|
||||||
|
fi
|
||||||
|
|
||||||
|
get_versions "${repo}" ${skip}
|
||||||
|
echo "# versions: ${#all[@]}"
|
||||||
|
rem_versions "${repo}"
|
Loading…
Reference in New Issue
Block a user