11#! /bin/bash
22#
33# Copyright 2021 Google LLC
4- # Modifications Copyright (C) 2025 OpenInfra Foundation Europe.
4+ # Modifications Copyright (C) 2025-2026 OpenInfra Foundation Europe.
55#
66# Licensed under the Apache License, Version 2.0 (the "License");
77# you may not use this file except in compliance with the License.
@@ -27,7 +27,8 @@ function err {
2727function docker_build {
2828 action=$1 # docker buildx operation, it should be either load or push.
2929 name=$2 # function name, e.g. apply-setters
30- tag=$3 # function tag, e.g. v1.2.3
30+ shift 2
31+ local tags=(" $@ " ) # one or more tags, e.g. v1.2.3 v1.2 v1
3132
3233 build_args=()
3334
@@ -53,15 +54,21 @@ function docker_build {
5354 echo " Setting build context to ${function_dir} "
5455 fi
5556
56- echo " building ${CR_REGISTRY} /${name} :${tag} "
57+ # Build tag arguments
58+ local tag_args=()
59+ for tag in " ${tags[@]} " ; do
60+ tag_args+=(-t " ${CR_REGISTRY} /${name} :${tag} " )
61+ done
62+
63+ echo " building ${CR_REGISTRY} /${name} with tags: ${tags[*]} "
5764
5865 case " ${action} " in
5966 load)
6067 IFS=' ' read -r -a extra_args_array <<< " ${EXTRA_BUILD_ARGS:-}"
6168
6269 # Use + conditional parameter expansion to protect from unbound array variable
6370 docker buildx build --load \
64- -t " ${CR_REGISTRY} / ${name} : ${tag }" \
71+ " ${tag_args[@] } " \
6572 -f " ${dockerfile} " \
6673 " ${build_args[@]+" ${build_args[@]} " } " \
6774 " ${extra_args_array[@]+" ${extra_args_array[@]} " } " \
@@ -71,7 +78,7 @@ function docker_build {
7178 IFS=' ' read -r -a extra_args_array <<< " ${EXTRA_BUILD_ARGS:-}"
7279 # build and push multi-arch image.
7380 docker buildx build --push \
74- -t " ${CR_REGISTRY} / ${name} : ${tag }" \
81+ " ${tag_args[@] } " \
7582 -f " ${dockerfile} " \
7683 --platform " linux/amd64,linux/arm64" \
7784 " ${build_args[@]+" ${build_args[@]} " } " \
0 commit comments