Merge ~virtustom/ubuntu-docker-images/+git/utils:main into ~ubuntu-docker-images/ubuntu-docker-images/+git/utils:main

Proposed by Tomáš Virtus
Status: Merged
Merged at revision: e8797c0a4ff6b29d4e4c97a3457f66e914b37de8
Proposed branch: ~virtustom/ubuntu-docker-images/+git/utils:main
Merge into: ~ubuntu-docker-images/ubuntu-docker-images/+git/utils:main
Diff against target: 59 lines (+16/-4)
1 file modified
tag-images.sh (+16/-4)
Reviewer Review Type Date Requested Status
Sergio Durigan Junior Approve
Thomas Bechtold Approve
Canonical Server Pending
Review via email: mp+409021@code.launchpad.net

Commit message

tag-image.sh: Small fixes

Description of the change

Tested on personal Docker Hub (https://hub.docker.com/r/ubuvirtus/ubuntu) with existing tags:

21.10
impish
impish-21.10_edge
20.04_edge
20.04_candidate
20.04_beta
20.04_stable
20.04
focal-20.04_edge
18.04_stable
bionic
bionic-18.04_edge

and command line (code changed to accept ubuvirtus):

  ./tag-images.sh -r docker -n ubuvirtus -- ubuntu

it creates:

I: Invoking multi-arch tagger for ubuvirtus/ubuntu:18.04 (source tag: bionic-18.04_edge) (on docker)
I: Invoking multi-arch tagger for ubuvirtus/ubuntu:18.04_edge (source tag: bionic-18.04_edge) (on docker)
I: Invoking multi-arch tagger for ubuvirtus/ubuntu:18.04_beta (source tag: bionic-18.04_edge) (on docker)
I: Invoking multi-arch tagger for ubuvirtus/ubuntu:18.04_candidate (source tag: bionic-18.04_edge) (on docker)
I: Invoking multi-arch tagger for ubuvirtus/ubuntu:focal (source tag: focal-20.04_edge) (on docker)
I: Invoking multi-arch tagger for ubuvirtus/ubuntu:21.10_edge (source tag: impish-21.10_edge) (on docker)
I: Not adding stable/beta/candidate tags to current devel release impish

To post a comment you must log in.
Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Thanks for the MP, Tomasz.

I haven't tested it "in production" but I think I found a problem with the suggested approach. Please take a look at my inline comment below :-).

Cheers.

review: Needs Fixing
Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Of course, another way to solve this is to move the definition of TAG_SUFFIXES inside the loop. I still prefer the first approach I outlined, though, because I see TAG_SUFFIXES as a const variable that shouldn't really be changed during the function.

Revision history for this message
Tomáš Virtus (virtustom) wrote :

OMG. That's... humiliating mistake. T_T Thanks for the find and the tip. Your 1st suggestion is what I'll do in a moment.

Revision history for this message
Tomáš Virtus (virtustom) wrote (last edit ):

This time tested. See updated MP description for details.

Revision history for this message
Thomas Bechtold (toabctl) :
review: Approve
Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Thanks, this LGTM now.

I will merge your branch tomorrow (it's too late for me right now). I just have a very small comment regarding the commit message: I think the "Fixes: e5f6309" is confusing, so IMO you can just get rid of it.

Thanks again.

review: Approve
Revision history for this message
Tomáš Virtus (virtustom) wrote :

Had the same doubt. Removed.

Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Thanks, this has been merged.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tag-images.sh b/tag-images.sh
2index b6dd208..0f90f5d 100755
3--- a/tag-images.sh
4+++ b/tag-images.sh
5@@ -118,7 +118,10 @@ EOF
6 do_tag_base_ubuntu_image ()
7 {
8 local image="ubuntu"
9- local -a TAG_SUFFIXES=( "stable" "beta" "candidate" "edge" )
10+ # These suffixes are for 'XX.YY_${suffix}' tags applied to
11+ # non-devel releases only. 'XX.YY_edge' tag is applied separately
12+ # to every release.
13+ local -a TAG_SUFFIXES=( "stable" "beta" "candidate" )
14
15 local -a IMAGE_TAGS EDGE_TAGS
16
17@@ -151,7 +154,7 @@ do_tag_base_ubuntu_image ()
18 fi
19
20 # Tag the DISTRONAME.
21- if [ -n "$FORCE" ] || ! grep -Fwq "${IMG_DISTRONAME}" <<< "${IMAGE_TAGS[@]}"; then
22+ if [ -n "$FORCE" ] || ! printf '%s\n' "${IMAGE_TAGS[@]}" | grep -Fxq "${IMG_DISTRONAME}"; then
23 info "Invoking multi-arch tagger for ${NAMESPACE}/${image}:${IMG_DISTRONAME} (source tag: ${EDGE_TAG_PREFIX}_edge) (on ${REGISTRY})"
24 tag_image \
25 "${image}" \
26@@ -160,7 +163,7 @@ do_tag_base_ubuntu_image ()
27 fi
28
29 # Tag the RELEASEVER
30- if [ -n "$FORCE" ] || ! grep -Fwq "${IMG_RELEASEVER}" <<< "${IMAGE_TAGS[@]}"; then
31+ if [ -n "$FORCE" ] || ! printf '%s\n' "${IMAGE_TAGS[@]}" | grep -Fxq "${IMG_RELEASEVER}"; then
32 info "Invoking multi-arch tagger for ${NAMESPACE}/${image}:${IMG_RELEASEVER} (source tag: ${EDGE_TAG_PREFIX}_edge) (on ${REGISTRY})"
33 tag_image \
34 "${image}" \
35@@ -168,6 +171,15 @@ do_tag_base_ubuntu_image ()
36 "${IMG_RELEASEVER}"
37 fi
38
39+ # Tag the RELEASEVER_edge
40+ if [ -n "$FORCE" ] || ! printf '%s\n' "${IMAGE_TAGS[@]}" | grep -Fxq "${IMG_RELEASEVER}_edge"; then
41+ info "Invoking multi-arch tagger for ${NAMESPACE}/${image}:${IMG_RELEASEVER}_edge (source tag: ${EDGE_TAG_PREFIX}_edge) (on ${REGISTRY})"
42+ tag_image \
43+ "${image}" \
44+ "${EDGE_TAG_PREFIX}_edge" \
45+ "${IMG_RELEASEVER}_edge"
46+ fi
47+
48 if [ "$IMG_DISTRONAME" = "$DISTRONAME_DEVEL" ]; then
49 info "Not adding stable/beta/candidate tags to current devel release $IMG_DISTRONAME"
50 continue
51@@ -175,7 +187,7 @@ do_tag_base_ubuntu_image ()
52
53 for tagsuffix in "${TAG_SUFFIXES[@]}"; do
54 # Tag each suffix.
55- if [ -n "$FORCE" ] || ! grep -Fwq "${IMG_RELEASEVER}_${tagsuffix}" <<< "${IMAGE_TAGS[@]}"; then
56+ if [ -n "$FORCE" ] || ! printf '%s\n' "${IMAGE_TAGS[@]}" | grep -Fxq "${IMG_RELEASEVER}_${tagsuffix}"; then
57 info "Invoking multi-arch tagger for ${NAMESPACE}/${image}:${IMG_RELEASEVER}_${tagsuffix} (source tag: ${EDGE_TAG_PREFIX}_edge) (on ${REGISTRY})"
58 tag_image \
59 "${image}" \

Subscribers

People subscribed via source and target branches