Skip to content

Commit

Permalink
fix: improve fetch_postgres_image_version() regexp
Browse files Browse the repository at this point in the history
Signed-off-by: Niccolò Fei <[email protected]>
  • Loading branch information
NiccoloFei committed Jul 24, 2024
1 parent 40e39a8 commit cbf018a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/repo_funcs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,19 @@ POSTGRESQL_LATEST_MAJOR_RELEASE=16

# Get the last postgres base image tag and update time
fetch_postgres_image_version() {
local suite="$1"; shift
local version="$1"; shift
local distro="$1"; shift
local item="$1"; shift

regexp="^${version}\\.[0-9]+-${distro}$"
if [[ ${version} -gt "${POSTGRESQL_LATEST_MAJOR_RELEASE}" ]]; then
regexp="^${version}beta[0-9]+-${distro}$"
fi

echo $regexp

curl -SsL "https://registry.hub.docker.com/v2/repositories/library/postgres/tags/?name=${distro}&ordering=last_updated&page_size=50" | \
jq -c ".results[] | select( .name | match(\"^${suite}.[a-z0-9]+-${distro}$\"))" | \
jq --arg regexp "$regexp" -c '.results[] | select( .name | match($regexp))' | \
jq -r ".${item}" | \
head -n1
}
Expand Down

0 comments on commit cbf018a

Please sign in to comment.