cozystack/packages/apps/opensearch/hack/update-versions.sh
Matthieu bb660b57c7
[opensearch] Address PR review feedback
Remove sysctl DaemonSet in favor of operator's built-in setVMMaxMapCount
init container, fix schema conflicts with required+empty default, fix
update-versions.sh YAML output format, and use $(MAKE) in Makefile.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Matthieu <matthieu@hidora.com>
2026-03-17 11:20:44 +01:00

53 lines
1.6 KiB
Bash
Executable file

#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
OPENSEARCH_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
VERSIONS_FILE="${OPENSEARCH_DIR}/files/versions.yaml"
# Supported major versions (newest first)
SUPPORTED_MAJOR_VERSIONS="3 2 1"
echo "Supported major versions: $SUPPORTED_MAJOR_VERSIONS"
# Check if skopeo is installed
if ! command -v skopeo &> /dev/null; then
echo "Error: skopeo is not installed. Please install skopeo and try again." >&2
exit 1
fi
# Check if jq is installed
if ! command -v jq &> /dev/null; then
echo "Error: jq is not installed. Please install jq and try again." >&2
exit 1
fi
# Get available image tags from Docker Hub
IMAGE="docker.io/opensearchproject/opensearch"
echo "Fetching available image tags from registry..."
TAGS=$(skopeo list-tags "docker://${IMAGE}" | jq -r '.Tags[]')
echo "# OpenSearch version mapping (major version -> image tag)" > "${VERSIONS_FILE}"
echo "# Auto-generated by hack/update-versions.sh - do not edit manually" >> "${VERSIONS_FILE}"
for MAJOR in $SUPPORTED_MAJOR_VERSIONS; do
# Find the latest stable release for this major version
LATEST=$(echo "$TAGS" \
| grep -E "^${MAJOR}\.[0-9]+\.[0-9]+$" \
| sort -t. -k1,1n -k2,2n -k3,3n \
| tail -1)
if [ -n "$LATEST" ]; then
echo "v${MAJOR}: latest tag is ${LATEST}"
echo "v${MAJOR}: \"${LATEST}\"" >> "${VERSIONS_FILE}"
else
echo "WARNING: No stable release found for major version ${MAJOR}" >&2
fi
done
echo ""
echo "Updated ${VERSIONS_FILE}:"
cat "${VERSIONS_FILE}"