Merge ~toabctl/ubuntu-docker-images/+git/utils:tag-filter into ~ubuntu-docker-images/ubuntu-docker-images/+git/utils:main

Proposed by Thomas Bechtold
Status: Merged
Merged at revision: 7469a2d7436260cc73a159288db0d014ef1a0111
Proposed branch: ~toabctl/ubuntu-docker-images/+git/utils:tag-filter
Merge into: ~ubuntu-docker-images/ubuntu-docker-images/+git/utils:main
Diff against target: 44 lines (+19/-0)
1 file modified
tag-images.sh (+19/-0)
Reviewer Review Type Date Requested Status
Sergio Durigan Junior Needs Fixing
Review via email: mp+405735@code.launchpad.net

Commit message

tag-images.sh: add --tag-filter to tag only a specific _edge tag
Currently the tag-images.sh script interates over all the given _edge
tags from the given images in the given namespace and adds the needed
tags (eg. _beta, _candidate or _stable). That's not always
wanted. Eg. when using the script in a CI pipeline where a job does
only update a specific image (eg. the "impish-21.10_edge" tagged
image), the script should only add the additional tags to that tagged
image.
With the new parameter, that's possible.
Assuming there are multiple _edge tags (eg. "impish-21.10_edge" and
"hirsute-21.04_edge") for a given image and --tag-filter is set to
"impish", the script will now only add the extra tags to the image
that is tagged with "impish-21.10_edge" .

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

Thanks for the MP, Thomas.

I like the idea of filtering tags; this is something I've been meaning to implement for a while TBH. I understand that this only works for Ubuntu base images for now, but hey, baby steps.

I'm leaving a comment about a discrepancy between how you declare the TAG_FILTER variable and how you use it (array vs. normal variable). With that fixed, I can merge the MP.

Thanks again.

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

Merged, thanks.

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 5e04f49..f4e212b 100755
3--- a/tag-images.sh
4+++ b/tag-images.sh
5@@ -88,6 +88,15 @@ Arguments:
6
7 --dry-run Do a dry run
8
9+ --tag-filter TAG_FILTER Do not tag all found "M.N-XX.YY_edge" tags for the given
10+ Namespace and images, but only the ones where "M.N"
11+ matches the given TAG_FILTER. Eg. if an image has the
12+ tags "impish-21.10_edge" and "hirsute-21.04_edge" and
13+ the TAG_FILTER is set to "impish", tagging will only be
14+ done for the "impish-21.10_edge" tag.
15+ Note: this currently only works for base images
16+ where the IMAGE name must be "ubuntu"
17+
18 -- IMAGE_1 IMAGE_2 ... IMAGE_N Images to tag. If not specified,
19 the script will obtain the list of
20 all images from REGISTRY/NAMESPACE
21@@ -132,6 +141,11 @@ do_tag_base_ubuntu_image ()
22 IMG_DISTRONAME=$(cut -d'-' -f1 <<< "$EDGE_TAG_PREFIX")
23 IMG_RELEASEVER=$(cut -d'-' -f2 <<< "$EDGE_TAG_PREFIX")
24
25+ if [ -n "$TAG_FILTER" ] && [ "$TAG_FILTER" != "$IMG_DISTRONAME" ]; then
26+ info "Skipping $edgetag due to --tag-filter=$TAG_FILTER"
27+ continue
28+ fi
29+
30 # Tag the DISTRONAME.
31 if [ -n "$FORCE" ] || ! grep -Fwq "${IMG_DISTRONAME}" <<< "${IMAGE_TAGS[@]}"; then
32 info "Invoking multi-arch tagger for ${NAMESPACE}/${image}:${IMG_DISTRONAME} (source tag: ${EDGE_TAG_PREFIX}_edge) (on ${REGISTRY})"
33@@ -332,6 +346,11 @@ while [ -n "$1" ]; do
34 shift 2
35 ;;
36
37+ "--tag-filter")
38+ TAG_FILTER="$2"
39+ shift 2
40+ ;;
41+
42 "-h"|"--help")
43 usage
44 exit 0

Subscribers

People subscribed via source and target branches