Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions addons/velero/template/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ function get_latest_release_version() {
function get_latest_tag_version() {
VAR_NAME=$1
local url=$2
local response
local version

version=$(curl -fsSL "$url" | \
grep -m1 '"name": "v' | \
# Fetch the full response before grepping. Under set -o pipefail, piping
# curl directly to grep -m1 can fail with exit code 23 when grep exits
# after the first match and closes the pipe. Using a here-string avoids
# the broken-pipe issue entirely.
response=$(curl -fsSL "$url")
version=$(grep -m1 '"name": "v' <<< "$response" | \
grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")

export "$VAR_NAME=$version"
Expand Down
Loading