Skip to content

Commit bd35aed

Browse files
mayastor-borstiagolobocastroniladrih
committed
chore(bors): merge pull request #803
803: Fix helm pins r=niladrih a=tiagolobocastro ci: fix pin.sh check for missing repo Co-authored-by: Tiago Castro <tiagolobocastro@gmail.com> Co-authored-by: Niladri Halder <niladri.halder26@gmail.com>
2 parents d2fb013 + a90bf1a commit bd35aed

2 files changed

Lines changed: 16 additions & 35 deletions

File tree

scripts/helm/pin.sh

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,6 @@ Examples:
4646
EOF
4747
}
4848

49-
oras_latest() {
50-
local repo="$1"
51-
local prefix="$2"
52-
53-
tags=$(oras repo tags "$repo")
54-
local error=$?
55-
if [[ $error -ne 0 ]]; then
56-
local capture
57-
capture=$(oras repo tags "$repo" 2>&1)
58-
# todo: can't find a better way to check if repository exists ahead of time
59-
if echo "$capture" | grep "404" &>/dev/null; then
60-
return 0
61-
fi
62-
return $error
63-
fi
64-
65-
echo "$tags" | { grep "^$prefix\." || true; } | sort -rt '.' -k4 -n | head -n 1
66-
}
6749
oci_latest() {
6850
local repo="$1"
6951
local prefix="$2"
@@ -95,12 +77,24 @@ oci_latest() {
9577
return $error
9678
fi
9779

80+
# Version not found, check if repo exists to distinguish repo vs version missing.
81+
local oras_output oras_error
82+
oras_output=$(oras repo tags "$repo" 2>&1)
83+
oras_error=$?
84+
85+
if [[ $oras_error -eq 0 ]]; then
86+
# Repo exists, version doesn't.
87+
return 0
88+
fi
89+
9890
# todo: can't find a better way to check if repository exists ahead of time
99-
if { oras repo tags "$repo" 2>&1 || :; } | grep "404" >/dev/null; then
91+
if echo "$oras_output" | grep "repository name not known to registry" >/dev/null; then
92+
# Repo doesn't exist.
10093
return 0
10194
fi
102-
log_error "Failed to fetch tags from $repo"
103-
return $error
95+
96+
log_error "Failed to fetch tags from $repo: $oras_output"
97+
return $oras_error
10498
}
10599
oci_next() {
106100
local repo="$1"
@@ -158,18 +152,6 @@ helm_pins_version_prefix() {
158152
fi
159153
echo "$pinned_version_prefix"
160154
}
161-
helm_pins_version_latest() {
162-
local pinned_oci_chart="$1"
163-
local pinned_version_prefix="$2"
164-
local pinned_version
165-
166-
pinned_version=$(oci_latest "$pinned_oci_chart" "$pinned_version_prefix")
167-
local error=$?
168-
if [[ $error -ne 0 ]]; then
169-
return $error
170-
fi
171-
echo "$pinned_version"
172-
}
173155
helm_pins_version() {
174156
local pinned_oci_chart="$1"
175157
local pinned_version_prefix="$2"

scripts/utils/repo.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ latest_release_branch() {
2525
--all \
2626
--list "$remote/release/*.*" \
2727
--format '%(refname:short)' \
28-
--sort 'refname' \
29-
| tail -n 1)
28+
| sort -V | tail -n 1)
3029

3130
if [ "$latest_release_branch" = "" ]; then
3231
latest_release_branch="$remote/release/0.0"

0 commit comments

Comments
 (0)