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: 6e96720a18a891cbc5b00c61225f8168ba8d398a
Proposed branch: ~virtustom/ubuntu-docker-images/+git/utils:main
Merge into: ~ubuntu-docker-images/ubuntu-docker-images/+git/utils:main
Diff against target: 62 lines (+42/-1)
1 file modified
tag-images.sh (+42/-1)
Reviewer Review Type Date Requested Status
Sergio Durigan Junior Approve
Thomas Bechtold Approve
Canonical Server Pending
Review via email: mp+409183@code.launchpad.net

Commit message

tag-images.sh: Tag latest/edge shorthand tags
Currently we don't update latest/edge shorthand tags. There's a plan
to implement tagging similar to snaps[1]. In the meantime, update
latest/edge tags according to the following rules:
  If the repository is 'lts',
    set both 'latest' and 'edge' tags to the latest LTS release.
  If the repository is 'ubuntu',
    set 'latest' tag to the latest stable release and
    set 'edge' tag to the devel release.
[1] https://snapcraft.io/docs/release-management

Description of the change

JIRA issue: https://warthogs.atlassian.net/browse/ROCKS-13

Valentin has more plans with regard to tagging channels similar to snaps, but he agreed that in the meantime the rules for tagging edge/latest are fine. I think it's not pretty (opinions welcome!).

I've tested it in my personal Docker Hub repository (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
hirsute-21.04_edge

and command line (code changed to accept ubuvirtus):

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

When I change the added comparison to check for 'ubuvirtus' instead of 'ubuntu', the output is:

I: Invoking multi-arch tagger for ubuvirtus/ubuntu:21.10_edge (source tag: impish-21.10_edge) (on docker)
I: Invoking multi-arch tagger for ubuvirtus/edge (source tag: impish-21.10_edge) (on docker)
I: Not adding stable/beta/candidate tags to current devel release impish
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:hirsute (source tag: hirsute-21.04_edge) (on docker)
I: Invoking multi-arch tagger for ubuvirtus/ubuntu:21.04 (source tag: hirsute-21.04_edge) (on docker)
I: Invoking multi-arch tagger for ubuvirtus/ubuntu:21.04_edge (source tag: hirsute-21.04_edge) (on docker)
I: Invoking multi-arch tagger for ubuvirtus/latest (source tag: hirsute-21.04_edge) (on docker)
I: Invoking multi-arch tagger for ubuvirtus/ubuntu:21.04_stable (source tag: hirsute-21.04_edge) (on docker)
I: Invoking multi-arch tagger for ubuvirtus/ubuntu:21.04_beta (source tag: hirsute-21.04_edge) (on docker)
I: Invoking multi-arch tagger for ubuvirtus/ubuntu:21.04_candidate (source tag: hirsute-21.04_edge) (on docker)

When I change the added comparison to check for 'ubuvirtus' instead of 'lts', the output is:

I: Invoking multi-arch tagger for ubuvirtus/ubuntu:hirsute (source tag: hirsute-21.04_edge) (on docker)
I: Invoking multi-arch tagger for ubuvirtus/ubuntu:21.04 (source tag: hirsute-21.04_edge) (on docker)
I: Invoking multi-arch tagger for ubuvirtus/ubuntu:21.04_edge (source tag: hirsute-21.04_edge) (on docker)
I: Invoking multi-arch tagger for ubuvirtus/ubuntu:21.04_stable (source tag: hirsute-21.04_edge) (on docker)
I: Invoking multi-arch tagger for ubuvirtus/ubuntu:21.04_beta (source tag: hirsute-21.04_edge) (on docker)
I: Invoking multi-arch tagger for ubuvirtus/ubuntu:21.04_candidate (source tag: hirsute-21.04_edge) (on docker)
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/latest (source tag: focal-20.04_edge) (on docker)
I: Invoking multi-arch tagger for ubuvirtus/edge (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
Thomas Bechtold (toabctl) :
review: Approve
Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Thanks for the MP, Tomasz.

I'm leaving a few comments regarding style, and that's the only reason why I'm marking this as "Needs Fixing". But otherwise, I don't have anything particular to add to the code. I just would like to point out that this code is relying heavily on "distro-info", so you will need to stay on top of it and make sure that it's up-to-date as soon as a new release is out.

Thanks.

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

Duly noted and all code comments should be addressed in latest commit. Tested again as in description with same result.

You are right about distro-info and it actually fails after the date of latest entry in the CSV file (/usr/share/distro-info/ubuntu.csv) gets out of date when invoked with --devel. I'll address this in later commit. Set as WIP for now.

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

Thanks for addressing the comments, Tomas.

FWIW, my comment regarding distro-info was more of a heads-up; I'm not expecting you to address this problem in this MP (I'd actually prefer if you filed a separate MP for that).

I'm approving this one, let me know if I should merge it as is :-).

Thanks.

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

Sorry for the delay. I had another onboarding task. Tested again with '-eq' instead of '=' with same results as in description.

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

Awesome, thank you.

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 0f90f5d..92ccaf3 100755
3--- a/tag-images.sh
4+++ b/tag-images.sh
5@@ -125,8 +125,10 @@ do_tag_base_ubuntu_image ()
6
7 local -a IMAGE_TAGS EDGE_TAGS
8
9- local DISTRONAME_DEVEL
10+ local DISTRONAME_DEVEL DISTRONAME_STABLE DISTRONAME_LTS
11 DISTRONAME_DEVEL=$(distro-info --devel)
12+ DISTRONAME_STABLE=$(distro-info --stable)
13+ DISTRONAME_LTS=$(distro-info --lts)
14
15 readarray -t IMAGE_TAGS < <(print_tags_for_image "${image}")
16
17@@ -180,6 +182,45 @@ do_tag_base_ubuntu_image ()
18 "${IMG_RELEASEVER}_edge"
19 fi
20
21+ local DO_TAG_LATEST=0 DO_TAG_EDGE=0
22+
23+ case "$NAMESPACE" in
24+ lts)
25+ case "$IMG_DISTRONAME" in
26+ "$DISTRONAME_LTS")
27+ DO_TAG_LATEST=1
28+ DO_TAG_EDGE=1
29+ ;;
30+ esac
31+ ;;
32+ ubuntu)
33+ case "$IMG_DISTRONAME" in
34+ "$DISTRONAME_STABLE")
35+ DO_TAG_LATEST=1
36+ ;;
37+ "$DISTRONAME_DEVEL")
38+ DO_TAG_EDGE=1
39+ ;;
40+ esac
41+ ;;
42+ esac
43+
44+ if [ "$DO_TAG_LATEST" -eq 1 ]; then
45+ info "Invoking multi-arch tagger for ${NAMESPACE}/latest (source tag: ${EDGE_TAG_PREFIX}_edge) (on ${REGISTRY})"
46+ tag_image \
47+ "${image}" \
48+ "${EDGE_TAG_PREFIX}_edge" \
49+ "latest"
50+ fi
51+
52+ if [ "$DO_TAG_EDGE" -eq 1 ]; then
53+ info "Invoking multi-arch tagger for ${NAMESPACE}/edge (source tag: ${EDGE_TAG_PREFIX}_edge) (on ${REGISTRY})"
54+ tag_image \
55+ "${image}" \
56+ "${EDGE_TAG_PREFIX}_edge" \
57+ "edge"
58+ fi
59+
60 if [ "$IMG_DISTRONAME" = "$DISTRONAME_DEVEL" ]; then
61 info "Not adding stable/beta/candidate tags to current devel release $IMG_DISTRONAME"
62 continue

Subscribers

People subscribed via source and target branches