Skip to content
46 changes: 45 additions & 1 deletion rebasebot-hook-scripts/go-replace_velero_oadp-1.5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" || \
Expand All @@ -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"
Expand All @@ -28,4 +73,3 @@ if grep -q "^replace $UPSTREAM_MODULE" "$GO_MOD_FILE"; then
else
echo "$REPLACE_LINE" >> "$GO_MOD_FILE"
fi

45 changes: 45 additions & 0 deletions rebasebot-hook-scripts/go-replace_velero_oadp-1.6.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" || \
Expand All @@ -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"
Expand Down
46 changes: 45 additions & 1 deletion rebasebot-hook-scripts/go-replace_velero_oadp-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -28,4 +73,3 @@ if grep -q "^replace $UPSTREAM_MODULE" "$GO_MOD_FILE"; then
else
echo "$REPLACE_LINE" >> "$GO_MOD_FILE"
fi

Binary file added tools/prow-merge-bot-configs/tui/tui
Binary file not shown.