@@ -46,24 +46,6 @@ Examples:
4646EOF
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- }
6749oci_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}
10599oci_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- }
173155helm_pins_version () {
174156 local pinned_oci_chart=" $1 "
175157 local pinned_version_prefix=" $2 "
0 commit comments