@@ -17,55 +17,84 @@ SIDECAR_IMAGE="${REPO}/objectstorage-sidecar"
17
17
18
18
# args to 'make build'
19
19
export DOCKER=" /buildx-entrypoint" # available in gcr.io/k8s-testimages/gcb-docker-gcloud image
20
- export BUILD_ARGS=" --push"
21
20
export PLATFORM
22
21
export SIDECAR_TAG=" ${SIDECAR_IMAGE} :${GIT_TAG} "
23
22
export CONTROLLER_TAG=" ${CONTROLLER_IMAGE} :${GIT_TAG} "
24
23
25
- make build
24
+ ADDITIONAL_BUILD_ARGS=" --push"
25
+ ADDITIONAL_CONTROLLER_TAGS=()
26
+ ADDITIONAL_SIDECAR_TAGS=()
26
27
27
28
# PULL_BASE_REF is 'main' for non-tagged commits on the main branch
28
29
if [[ " ${PULL_BASE_REF} " == main ]]; then
29
30
echo " ! ! ! this is a main branch build ! ! !"
30
31
# 'main' tag follows the main branch head
31
- gcloud container images add-tag " ${CONTROLLER_TAG} " " ${ CONTROLLER_IMAGE} :main"
32
- gcloud container images add-tag " ${SIDECAR_TAG} " " ${ SIDECAR_IMAGE} :main"
32
+ ADDITIONAL_CONTROLLER_TAGS+=( " ${CONTROLLER_IMAGE} :main" )
33
+ ADDITIONAL_SIDECAR_TAGS+=( " ${SIDECAR_IMAGE} :main" )
33
34
# 'latest' tag follows 'main' for easy use by developers
34
- gcloud container images add-tag " ${CONTROLLER_TAG} " " ${ CONTROLLER_IMAGE} :latest"
35
- gcloud container images add-tag " ${SIDECAR_TAG} " " ${ SIDECAR_IMAGE} :latest"
35
+ ADDITIONAL_CONTROLLER_TAGS+=( " ${CONTROLLER_IMAGE} :latest" )
36
+ ADDITIONAL_SIDECAR_TAGS+=( " ${SIDECAR_IMAGE} :latest" )
36
37
fi
37
38
38
39
# PULL_BASE_REF is 'release-*' for non-tagged commits on release branches
39
40
if [[ " ${PULL_BASE_REF} " == release-* ]]; then
40
41
echo " ! ! ! this is a ${PULL_BASE_REF} release branch build ! ! !"
41
42
# 'release-*' tags that follow each release branch head
42
- gcloud container images add-tag " ${CONTROLLER_TAG} " " ${ CONTROLLER_IMAGE} :${PULL_BASE_REF} "
43
- gcloud container images add-tag " ${SIDECAR_TAG} " " ${ SIDECAR_IMAGE} :${PULL_BASE_REF} "
43
+ ADDITIONAL_CONTROLLER_TAGS+=( " ${CONTROLLER_IMAGE} :${PULL_BASE_REF} " )
44
+ ADDITIONAL_SIDECAR_TAGS+=( " ${SIDECAR_IMAGE} :${PULL_BASE_REF} " )
44
45
fi
45
46
46
47
# PULL_BASE_REF is 'controller/TAG' for a tagged controller release
47
48
if [[ " ${PULL_BASE_REF} " == controller/* ]]; then
48
49
echo " ! ! ! this is a tagged controller release ! ! !"
49
50
TAG=" ${PULL_BASE_REF# controller/* } "
50
- gcloud container images add-tag " ${CONTROLLER_TAG} " " ${CONTROLLER_IMAGE} :${TAG} "
51
+ # when tagging a release image, do not apply any other tags other than the release tag
52
+ # the registry.k8s.io scripting does not handle images with multiple tags
53
+ ADDITIONAL_CONTROLLER_TAGS=()
54
+ CONTROLLER_TAG=" ${CONTROLLER_IMAGE} :${TAG} "
51
55
fi
52
56
53
57
# PULL_BASE_REF is 'sidecar/TAG' for a tagged sidecar release
54
58
if [[ " ${PULL_BASE_REF} " == sidecar/* ]]; then
55
59
echo " ! ! ! this is a tagged sidecar release ! ! !"
56
60
TAG=" ${PULL_BASE_REF# sidecar/* } "
57
- gcloud container images add-tag " ${SIDECAR_TAG} " " ${SIDECAR_IMAGE} :${TAG} "
61
+ # when tagging a release image, do not apply any other tags other than the release tag
62
+ # the registry.k8s.io scripting does not handle images with multiple tags
63
+ ADDITIONAL_SIDECAR_TAGS=()
64
+ SIDECAR_TAG=" ${SIDECAR_IMAGE} :${TAG} "
58
65
fi
59
66
60
67
# PULL_BASE_REF is 'v0.y.z*' for tagged alpha releases where controller and sidecar are released simultaneously
61
68
# hand wave over complex matching logic by just looking for 'v0.' prefix
62
69
if [[ " ${PULL_BASE_REF} " == ' v0.' * ]]; then
63
70
echo " ! ! ! this is a tagged controller + sidecar release ! ! !"
64
71
TAG=" ${PULL_BASE_REF} "
65
- gcloud container images add-tag " ${CONTROLLER_TAG} " " ${CONTROLLER_IMAGE} :${TAG} "
66
- gcloud container images add-tag " ${SIDECAR_TAG} " " ${SIDECAR_IMAGE} :${TAG} "
72
+ # when tagging a release image, do not apply any other tags other than the release tag
73
+ # the registry.k8s.io scripting does not handle images with multiple tags
74
+ ADDITIONAL_CONTROLLER_TAGS=()
75
+ ADDITIONAL_SIDECAR_TAGS=()
76
+ CONTROLLER_TAG=" ${CONTROLLER_IMAGE} :${TAG} "
77
+ SIDECAR_TAG=" ${SIDECAR_IMAGE} :${TAG} "
67
78
fi
68
79
69
80
# else, PULL_BASE_REF is something that doesn't release image(s) to staging, like:
70
81
# - a random branch name (e.g., feature-xyz)
71
82
# - a version tag for a subdir with no image associated (e.g., client/v0.2.0, proto/v0.2.0)
83
+
84
+ # This script's tagging should be less error-prone if 'docker buildx' has all the tags that an image
85
+ # will be tagged with during the build process. All tags are applied at once without need to
86
+ # maintain tooling for adding tags to manifests after build.
87
+
88
+ BUILD_ARGS=" ${ADDITIONAL_BUILD_ARGS} "
89
+ for tag in " ${ADDITIONAL_CONTROLLER_TAGS[@]} " ; do
90
+ BUILD_ARGS=" ${BUILD_ARGS} --tag=${tag} "
91
+ done
92
+ export BUILD_ARGS
93
+ make build.controller
94
+
95
+ BUILD_ARGS=" ${ADDITIONAL_BUILD_ARGS} "
96
+ for tag in " ${ADDITIONAL_SIDECAR_TAGS[@]} " ; do
97
+ BUILD_ARGS=" ${BUILD_ARGS} --tag=${tag} "
98
+ done
99
+ export BUILD_ARGS
100
+ make build.sidecar
0 commit comments