@@ -204,6 +204,23 @@ update_required() {
204204 fi
205205}
206206
207+ # The docker tag could either be a git tag, a git branch, or a modified git branch
208+ # The modified git branch can happen for release branches, where release/x becomes release-x
209+ hash_from_docker_tag () {
210+ local git_remote=" $1 "
211+ local docker_tag=" $2 "
212+ local hash
213+ hash=$( git ls-remote " $git_remote " " refs/heads/$docker_tag " | awk ' {print substr($1, 1, 12)}' )
214+ error=$?
215+ if [ -z " $hash " ] || [ $error -ne 0 ]; then
216+ # rewrite the release-x to release/x
217+ local git_branch
218+ git_branch=${docker_tag/ -// }
219+ hash=$( git ls-remote " $git_remote " " refs/heads/$git_branch " | awk ' {print substr($1, 1, 12)}' )
220+ fi
221+ echo " $hash "
222+ }
223+
207224PIN=" helm-pins"
208225CHART_REGISTRY=" ghcr.io"
209226CHART_NAMESPACE=" openebs/$PIN "
264281# We could use get_hash but this wouldn't work on "local" commits
265282if [[ -z " ${EXT_HASH:- } " ]]; then
266283 DATA_REMOTE=$( git remote get-url origin)
267- EXT_HASH=$( git ls-remote " $DATA_REMOTE " " refs/heads/ $TAG " | awk ' {print substr($1, 1, 12)} ' )
284+ EXT_HASH=$( hash_from_docker_tag " $DATA_REMOTE " " $TAG " )
268285fi
269286# We could use the submodule dep, but I've noticed that it may be pointing to a commit part of a
270287# merge commit, and in this case there's no equivalent docker image
271288if [[ -z " ${CTRL_HASH:- } " ]]; then
272289 DATA_REMOTE=$( git remote get-url origin | sed ' s/mayastor-extensions/mayastor-control-plane/' )
273- CTRL_HASH=$( git ls-remote " $DATA_REMOTE " " refs/heads/ $TAG " | awk ' {print substr($1, 1, 12)} ' )
290+ CTRL_HASH=$( hash_from_docker_tag " $DATA_REMOTE " " $TAG " )
274291fi
275292if [[ -z " ${DATA_HASH:- } " ]]; then
276293 DATA_REMOTE=$( git remote get-url origin | sed ' s/mayastor-extensions/mayastor/' )
277- DATA_HASH=$( git ls-remote " $DATA_REMOTE " " refs/heads/ $TAG " | awk ' {print substr($1, 1, 12)} ' )
294+ DATA_HASH=$( hash_from_docker_tag " $DATA_REMOTE " " $TAG " )
278295fi
279296if [[ -z " ${DATE_TIME:- } " ]]; then
280297 DATE_TIME=$( date +" %Y-%m-%d-%H-%M-%S" )
@@ -298,6 +315,10 @@ echo "Control-Plane hash : $CTRL_HASH"
298315echo " Data-Plane hash : $DATA_HASH "
299316echo " Chart Timestamp : $DATE_TIME "
300317
318+ if [ -z " ${EXT_HASH:- } " ] || [ -z " ${CTRL_HASH:- } " ] || [ -z " ${DATA_HASH:- } " ]; then
319+ log_fatal " Failed to retrieve the hashes"
320+ fi
321+
301322if [ ! " ${UNPIN_CHART:- } " = " true" ] && [[ " $PINNED_VERSION " != " $PINNED_VERSION_PREFIX .1" ]]; then
302323 UPDATE=$( update_required " $PINNED_OCI_CHART " " $PINNED_VERSION_PREFIX " " $PINNED_VERSION " " $EXT_HASH " " $CTRL_HASH " " $DATA_HASH " )
303324 if [[ " $UPDATE " = " false" ]]; then
0 commit comments