From 1512b1f7f3b3348936465d56f6badc34afa6181c Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Tue, 3 Oct 2023 22:42:49 +0200 Subject: [PATCH] new: [mongo] provide ``upstream-versions`` hook --- mongo/hooks/upstream-versions | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 mongo/hooks/upstream-versions diff --git a/mongo/hooks/upstream-versions b/mongo/hooks/upstream-versions new file mode 100755 index 0000000..dbccfb6 --- /dev/null +++ b/mongo/hooks/upstream-versions @@ -0,0 +1,36 @@ +#!/bin/bash + +## List upstream available versions in reverse chronological order +## +## These versions information will be the input for the version information +## usually used by the build process. +## A external query of upstream sources will be done. +## + +## This script is launched by ``charm upstream-versions`` and will receive these env variables +## +## +## VERSION_LIMIT ## limit number of version to read +## +## +## The script CWD will be the root of the charm directory +## + +DOCKER_IMAGE_NAME=mongo + +semver:normalize() { + local upstream_version="$1" + echo "$upstream_version" +} + + +upstream:list() { + local limit=${1:-5} + docker-tags-fetch "$DOCKER_IMAGE_NAME" -l "${limit}" -f "^[0-9]+\.[0-9]+\.[0-9]+$" | + sort -rV +} + + +while read -r "upstream_version"; do + printf "%s %s\n" "$(semver:normalize "${upstream_version}")" "$upstream_version" +done < <(upstream:list "${VERSION_LIMIT}")