diff --git a/rebasebot-hook-scripts/go-replace_velero_oadp-1.5.sh b/rebasebot-hook-scripts/go-replace_velero_oadp-1.5.sh index 113c24b..9592339 100755 --- a/rebasebot-hook-scripts/go-replace_velero_oadp-1.5.sh +++ b/rebasebot-hook-scripts/go-replace_velero_oadp-1.5.sh @@ -4,6 +4,36 @@ set -euo pipefail DOWNSTREAM_BRANCH="oadp-1.5" DOWNSTREAM_MODULE="github.com/openshift/velero" GO_MOD_FILE="go.mod" +UPSTREAM_VELERO_MAJOR_VERSION="v1.16" + +fetch_github_api() { + local url="$1" + if [ -n "${GITHUB_TOKEN:-}" ]; then + curl -fsSL -H "Authorization: Bearer $GITHUB_TOKEN" "$url" + else + curl -fsSL "$url" + fi +} + +fetch_all_velero_tags() { + local page=1 + local combined="" + while :; do + local body + if ! body="$(fetch_github_api "https://api.github.com/repos/velero-io/velero/tags?per_page=100&page=$page")"; then + echo "Failed to fetch Velero tags from GitHub API (page $page)" >&2 + exit 1 + fi + combined="${combined}"$'\n'"${body}" + local count + count="$(printf '%s\n' "$body" | grep -c "\"name\": \"" || true)" + if [ "$count" -lt 100 ]; then + break + fi + page=$((page + 1)) + done + printf '%s\n' "$combined" +} # Detect which velero module path the project uses (vmware-tanzu or velero-io) if grep -qE "require.*github\.com/velero-io/velero " "$GO_MOD_FILE" || \ @@ -15,6 +45,21 @@ fi REPLACE_LINE="replace $UPSTREAM_MODULE => $DOWNSTREAM_MODULE $DOWNSTREAM_BRANCH" +# Update require entries (both single-line and block forms) to the latest aligned upstream Velero release tag. +TAGS_BODY="$(fetch_all_velero_tags)" +UPSTREAM_VELERO_TAG="$( + printf '%s\n' "$TAGS_BODY" \ + | grep -Eo "\"name\": \"${UPSTREAM_VELERO_MAJOR_VERSION}\.[0-9]+\"" \ + | awk -F'"' '{print $4}' \ + | sort -V \ + | tail -n1 +)" +if [ -z "$UPSTREAM_VELERO_TAG" ]; then + echo "Failed to determine aligned upstream Velero tag for ${UPSTREAM_VELERO_MAJOR_VERSION}.x" >&2 + exit 1 +fi +sed -Ei "s|^([[:space:]]*(require[[:space:]]+)?$UPSTREAM_MODULE)[[:space:]]+[^[:space:]]+|\\1 $UPSTREAM_VELERO_TAG|" "$GO_MOD_FILE" + # Remove any stale replace for the other module path if [ "$UPSTREAM_MODULE" = "github.com/velero-io/velero" ]; then sed -i '/^replace github\.com\/vmware-tanzu\/velero /d' "$GO_MOD_FILE" @@ -28,4 +73,3 @@ if grep -q "^replace $UPSTREAM_MODULE" "$GO_MOD_FILE"; then else echo "$REPLACE_LINE" >> "$GO_MOD_FILE" fi - diff --git a/rebasebot-hook-scripts/go-replace_velero_oadp-1.6.sh b/rebasebot-hook-scripts/go-replace_velero_oadp-1.6.sh index b9d162e..60d5a92 100755 --- a/rebasebot-hook-scripts/go-replace_velero_oadp-1.6.sh +++ b/rebasebot-hook-scripts/go-replace_velero_oadp-1.6.sh @@ -4,6 +4,36 @@ set -euo pipefail DOWNSTREAM_BRANCH="oadp-1.6" DOWNSTREAM_MODULE="github.com/openshift/velero" GO_MOD_FILE="go.mod" +UPSTREAM_VELERO_MAJOR_VERSION="v1.18" + +fetch_github_api() { + local url="$1" + if [ -n "${GITHUB_TOKEN:-}" ]; then + curl -fsSL -H "Authorization: Bearer $GITHUB_TOKEN" "$url" + else + curl -fsSL "$url" + fi +} + +fetch_all_velero_tags() { + local page=1 + local combined="" + while :; do + local body + if ! body="$(fetch_github_api "https://api.github.com/repos/velero-io/velero/tags?per_page=100&page=$page")"; then + echo "Failed to fetch Velero tags from GitHub API (page $page)" >&2 + exit 1 + fi + combined="${combined}"$'\n'"${body}" + local count + count="$(printf '%s\n' "$body" | grep -c "\"name\": \"" || true)" + if [ "$count" -lt 100 ]; then + break + fi + page=$((page + 1)) + done + printf '%s\n' "$combined" +} # Detect which velero module path the project uses (vmware-tanzu or velero-io) if grep -qE "require.*github\.com/velero-io/velero " "$GO_MOD_FILE" || \ @@ -15,6 +45,21 @@ fi REPLACE_LINE="replace $UPSTREAM_MODULE => $DOWNSTREAM_MODULE $DOWNSTREAM_BRANCH" +# Update require entries (both single-line and block forms) to the latest aligned upstream Velero release tag. +TAGS_BODY="$(fetch_all_velero_tags)" +UPSTREAM_VELERO_TAG="$( + printf '%s\n' "$TAGS_BODY" \ + | grep -Eo "\"name\": \"${UPSTREAM_VELERO_MAJOR_VERSION}\.[0-9]+(-rc\.[0-9]+)?\"" \ + | awk -F'"' '{print $4}' \ + | sort -V \ + | tail -n1 +)" +if [ -z "$UPSTREAM_VELERO_TAG" ]; then + echo "Failed to determine aligned upstream Velero tag for ${UPSTREAM_VELERO_MAJOR_VERSION}.x" >&2 + exit 1 +fi +sed -Ei "s|^([[:space:]]*(require[[:space:]]+)?$UPSTREAM_MODULE)[[:space:]]+[^[:space:]]+|\\1 $UPSTREAM_VELERO_TAG|" "$GO_MOD_FILE" + # Remove any stale replace for the other module path if [ "$UPSTREAM_MODULE" = "github.com/velero-io/velero" ]; then sed -i '/^replace github\.com\/vmware-tanzu\/velero /d' "$GO_MOD_FILE" diff --git a/rebasebot-hook-scripts/go-replace_velero_oadp-dev.sh b/rebasebot-hook-scripts/go-replace_velero_oadp-dev.sh index ab26718..2c872fa 100755 --- a/rebasebot-hook-scripts/go-replace_velero_oadp-dev.sh +++ b/rebasebot-hook-scripts/go-replace_velero_oadp-dev.sh @@ -5,6 +5,35 @@ DOWNSTREAM_BRANCH="oadp-dev" DOWNSTREAM_MODULE="github.com/openshift/velero" GO_MOD_FILE="go.mod" +fetch_github_api() { + local url="$1" + if [ -n "${GITHUB_TOKEN:-}" ]; then + curl -fsSL -H "Authorization: Bearer $GITHUB_TOKEN" "$url" + else + curl -fsSL "$url" + fi +} + +fetch_all_velero_tags() { + local page=1 + local combined="" + while :; do + local body + if ! body="$(fetch_github_api "https://api.github.com/repos/velero-io/velero/tags?per_page=100&page=$page")"; then + echo "Failed to fetch Velero tags from GitHub API (page $page)" >&2 + exit 1 + fi + combined="${combined}"$'\n'"${body}" + local count + count="$(printf '%s\n' "$body" | grep -c "\"name\": \"" || true)" + if [ "$count" -lt 100 ]; then + break + fi + page=$((page + 1)) + done + printf '%s\n' "$combined" +} + # Detect which velero module path the project uses (vmware-tanzu or velero-io) if grep -qE "require.*github\.com/velero-io/velero " "$GO_MOD_FILE" || \ grep -qE "^\s+github\.com/velero-io/velero " "$GO_MOD_FILE"; then @@ -15,6 +44,22 @@ fi REPLACE_LINE="replace $UPSTREAM_MODULE => $DOWNSTREAM_MODULE $DOWNSTREAM_BRANCH" +# Update require entries (both single-line and block forms) to the latest upstream Velero tag. +# Intentionally considers RC tags as valid upstream targets for oadp-dev alignment. +TAGS_BODY="$(fetch_all_velero_tags)" +UPSTREAM_VELERO_TAG="$( + printf '%s\n' "$TAGS_BODY" \ + | grep -Eo "\"name\": \"v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?\"" \ + | awk -F'"' '{print $4}' \ + | sort -V \ + | tail -n1 +)" +if [ -z "$UPSTREAM_VELERO_TAG" ]; then + echo "Failed to determine latest upstream Velero tag" >&2 + exit 1 +fi +sed -Ei "s|^([[:space:]]*(require[[:space:]]+)?$UPSTREAM_MODULE)[[:space:]]+[^[:space:]]+|\\1 $UPSTREAM_VELERO_TAG|" "$GO_MOD_FILE" + # Remove any stale replace for the other module path if [ "$UPSTREAM_MODULE" = "github.com/velero-io/velero" ]; then sed -i '/^replace github\.com\/vmware-tanzu\/velero /d' "$GO_MOD_FILE" @@ -28,4 +73,3 @@ if grep -q "^replace $UPSTREAM_MODULE" "$GO_MOD_FILE"; then else echo "$REPLACE_LINE" >> "$GO_MOD_FILE" fi - diff --git a/tools/prow-merge-bot-configs/tui/tui b/tools/prow-merge-bot-configs/tui/tui new file mode 100755 index 0000000..15db94c Binary files /dev/null and b/tools/prow-merge-bot-configs/tui/tui differ