-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This new task "apply-tags" allows specifying additional-tags that will be added to the specified image. STONEBLD-2418 Signed-off-by: mkosiarc <[email protected]>
- Loading branch information
Showing
4 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# apply-tags task | ||
|
||
Apply-tags task will apply additional tags to the specified IMAGE. These additional tags can be provided via the ADDITIONAL_TAGS array parameter or they can also be provided in the image label "konflux.additional-tags". If you specify more than one additional tag in the label, they must be separated by a comma, e.g: | ||
|
||
``` | ||
LABEL konflux.additional-tags="tag1, tag2" | ||
``` | ||
|
||
## Parameters | ||
|name|description|default value|required| | ||
|---|---|---|---| | ||
|IMAGE|Reference of image that was pushed to registry in the buildah task.||true| | ||
|ADDITIONAL_TAGS|Additional tags that will be applied to the image in the registry.|[]|false| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
labels: | ||
app.kubernetes.io/version: "0.1" | ||
annotations: | ||
tekton.dev/pipelines.minVersion: "0.12.1" | ||
tekton.dev/tags: "appstudio, hacbs" | ||
name: apply-tags | ||
spec: | ||
description: >- | ||
Applies additional tags to the built image. | ||
params: | ||
- name: IMAGE | ||
description: Reference of image that was pushed to registry in the buildah task. | ||
type: string | ||
- name: ADDITIONAL_TAGS | ||
description: Additional tags that will be applied to the image in the registry. | ||
type: array | ||
default: [] | ||
steps: | ||
- name: apply-additional-tags-from-parameter | ||
image: registry.access.redhat.com/ubi9/skopeo:9.4-6@sha256:c4d70dec3eb0a0c831490192145ea25431fe04d1cf307f8d61e2d87adb41e7e3 | ||
args: | ||
- $(params.ADDITIONAL_TAGS) | ||
env: | ||
- name: IMAGE | ||
value: $(params.IMAGE) | ||
script: | | ||
#!/bin/bash | ||
if [ "$#" -ne 0 ]; then | ||
IMAGE_WITHOUT_TAG=$(echo "$IMAGE" | sed 's/:[^:]*$//') | ||
for tag in "$@"; do | ||
echo "Applying tag $tag" | ||
skopeo copy docker://$IMAGE docker://$IMAGE_WITHOUT_TAG:$tag | ||
done | ||
else | ||
echo "No additional tags parameter specified" | ||
fi | ||
- name: apply-additional-tags-from-image-label | ||
image: registry.access.redhat.com/ubi9/skopeo:9.4-6@sha256:c4d70dec3eb0a0c831490192145ea25431fe04d1cf307f8d61e2d87adb41e7e3 | ||
env: | ||
- name: IMAGE | ||
value: $(params.IMAGE) | ||
script: | | ||
#!/bin/bash | ||
ADDITIONAL_TAGS_FROM_IMAGE_LABEL=$(skopeo inspect --format '{{ index .Labels "konflux.additional-tags" }}' docker://$IMAGE) | ||
if [ -n "${ADDITIONAL_TAGS_FROM_IMAGE_LABEL}" ]; then | ||
IFS=', ' read -r -a tags_array <<< "$ADDITIONAL_TAGS_FROM_IMAGE_LABEL" | ||
IMAGE_WITHOUT_TAG=$(echo "$IMAGE" | sed 's/:[^:]*$//') | ||
for tag in "${tags_array[@]}" | ||
do | ||
echo "Applying tag $tag" | ||
skopeo copy docker://$IMAGE docker://$IMAGE_WITHOUT_TAG:$tag | ||
done | ||
else | ||
echo "No additional tags specified in the image labels" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Konflux Build team |