Task buildah: add feature to allow pushing additional tags#1382
Task buildah: add feature to allow pushing additional tags#1382kastl-ars wants to merge 3 commits into
Conversation
Signed-off-by: Johannes Kastl <johannes.kastl@atvantage.com>
…al tags This feature allows specifying additional tags like the commit hash or the date or similar, that will be used in addition to "latest". Please note, those tags need to be strings, not commands like $(date +%Y%m%d).
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
|
/kind feature |
Diff between version 0.9 and 0.10diff --git a/task/buildah/0.9/README.md b/task/buildah/0.10/README.md
index 4ac13c1..254298d 100644
--- a/task/buildah/0.9/README.md
+++ b/task/buildah/0.10/README.md
@@ -10,7 +10,7 @@ to assemble a container image, then pushes that image to a container registry.
## Install the Task
```
-kubectl apply -f https://api.hub.tekton.dev/v1/resource/tekton/task/buildah/0.9/raw
+kubectl apply -f https://api.hub.tekton.dev/v1/resource/tekton/task/buildah/0.10/raw
```
## Parameters
diff --git a/task/buildah/0.9/buildah.yaml b/task/buildah/0.10/buildah.yaml
index 91e087b..4927d53 100644
--- a/task/buildah/0.9/buildah.yaml
+++ b/task/buildah/0.10/buildah.yaml
@@ -4,7 +4,7 @@ kind: Task
metadata:
name: buildah
labels:
- app.kubernetes.io/version: "0.9"
+ app.kubernetes.io/version: "0.10"
annotations:
tekton.dev/categories: Image Build
tekton.dev/pipelines.minVersion: "0.50.0"
@@ -53,6 +53,11 @@ spec:
- name: SKIP_PUSH
description: Skip pushing the built image
default: "false"
+ - name: ADDITIONAL_TAGS
+ type: string
+ default: ""
+ description: |
+ Additional tags for pushing the image.
- name: BUILD_ARGS
description: Dockerfile build arguments, array of key=value
type: array
@@ -96,6 +101,8 @@ spec:
value: $(params.PUSH_EXTRA_ARGS)
- name: PARAM_SKIP_PUSH
value: $(params.SKIP_PUSH)
+ - name: PARAMS_ADDITIONAL_TAGS
+ value: $(params.ADDITIONAL_TAGS)
args:
- $(params.BUILD_ARGS[*])
script: |
@@ -117,6 +124,15 @@ spec:
buildah ${CERT_DIR_FLAG} "--storage-driver=${PARAM_STORAGE_DRIVER}" push \
"--tls-verify=${PARAM_TLSVERIFY}" --digestfile /tmp/image-digest ${PARAM_PUSH_EXTRA_ARGS} \
"${PARAM_IMAGE}" "docker://${PARAM_IMAGE}"
+ # push additional tags, if PARAMS_ADDITIONAL_TAGS is not empty
+ # shellcheck disable=SC2046,SC2086
+ if [ -n "${PARAMS_ADDITIONAL_TAGS}" ]; then
+ for tag in ${PARAMS_ADDITIONAL_TAGS};do
+ buildah ${CERT_DIR_FLAG} "--storage-driver=${PARAM_STORAGE_DRIVER}" push \
+ "--tls-verify=${PARAM_TLSVERIFY}" --digestfile /tmp/image-digest ${PARAM_PUSH_EXTRA_ARGS} \
+ "${PARAM_IMAGE}" "docker://${PARAM_IMAGE}":${tag}
+ done
+ fi
tee "$(results.IMAGE_DIGEST.path)" < /tmp/image-digest
printf '%s' "${PARAM_IMAGE}" | tee "$(results.IMAGE_URL.path)"
volumeMounts: |
| kubectl apply -f https://api.hub.tekton.dev/v1/resource/tekton/task/buildah/0.10/raw | ||
| ``` | ||
|
|
||
| ## Parameters |
There was a problem hiding this comment.
ADDITIONAL_TAGS param is missing isn't it ?
There was a problem hiding this comment.
You are right, I forgot. I just pushed a commit with the README changes.
Signed-off-by: Johannes Kastl <johannes.kastl@atvantage.com>
1bcb300 to
c541a21
Compare
Diff between version 0.9 and 0.10diff --git a/task/buildah/0.9/README.md b/task/buildah/0.10/README.md
index 4ac13c1..e44b395 100644
--- a/task/buildah/0.9/README.md
+++ b/task/buildah/0.10/README.md
@@ -10,7 +10,7 @@ to assemble a container image, then pushes that image to a container registry.
## Install the Task
```
-kubectl apply -f https://api.hub.tekton.dev/v1/resource/tekton/task/buildah/0.9/raw
+kubectl apply -f https://api.hub.tekton.dev/v1/resource/tekton/task/buildah/0.10/raw
```
## Parameters
@@ -32,6 +32,8 @@ kubectl apply -f https://api.hub.tekton.dev/v1/resource/tekton/task/buildah/0.9/
* **PUSH_EXTRA_ARGS**: Extra parameters passed for the push command when
pushing images. WARNING - must be sanitized to avoid command injection
(_default:_ `""`)
+* **ADDITIONAL_TAGS**: Additional tags for the newly built image, like a date or
+ a commit hash. Must be plain text, no commands allowed (_default:_ empty)
* **SKIP_PUSH**: Skip pushing the built image (_default:_ `false`)
* **BUILD_ARGS**: Dockerfile build arguments, array of key=value (_default:_ [""])
diff --git a/task/buildah/0.9/buildah.yaml b/task/buildah/0.10/buildah.yaml
index 91e087b..4927d53 100644
--- a/task/buildah/0.9/buildah.yaml
+++ b/task/buildah/0.10/buildah.yaml
@@ -4,7 +4,7 @@ kind: Task
metadata:
name: buildah
labels:
- app.kubernetes.io/version: "0.9"
+ app.kubernetes.io/version: "0.10"
annotations:
tekton.dev/categories: Image Build
tekton.dev/pipelines.minVersion: "0.50.0"
@@ -53,6 +53,11 @@ spec:
- name: SKIP_PUSH
description: Skip pushing the built image
default: "false"
+ - name: ADDITIONAL_TAGS
+ type: string
+ default: ""
+ description: |
+ Additional tags for pushing the image.
- name: BUILD_ARGS
description: Dockerfile build arguments, array of key=value
type: array
@@ -96,6 +101,8 @@ spec:
value: $(params.PUSH_EXTRA_ARGS)
- name: PARAM_SKIP_PUSH
value: $(params.SKIP_PUSH)
+ - name: PARAMS_ADDITIONAL_TAGS
+ value: $(params.ADDITIONAL_TAGS)
args:
- $(params.BUILD_ARGS[*])
script: |
@@ -117,6 +124,15 @@ spec:
buildah ${CERT_DIR_FLAG} "--storage-driver=${PARAM_STORAGE_DRIVER}" push \
"--tls-verify=${PARAM_TLSVERIFY}" --digestfile /tmp/image-digest ${PARAM_PUSH_EXTRA_ARGS} \
"${PARAM_IMAGE}" "docker://${PARAM_IMAGE}"
+ # push additional tags, if PARAMS_ADDITIONAL_TAGS is not empty
+ # shellcheck disable=SC2046,SC2086
+ if [ -n "${PARAMS_ADDITIONAL_TAGS}" ]; then
+ for tag in ${PARAMS_ADDITIONAL_TAGS};do
+ buildah ${CERT_DIR_FLAG} "--storage-driver=${PARAM_STORAGE_DRIVER}" push \
+ "--tls-verify=${PARAM_TLSVERIFY}" --digestfile /tmp/image-digest ${PARAM_PUSH_EXTRA_ARGS} \
+ "${PARAM_IMAGE}" "docker://${PARAM_IMAGE}":${tag}
+ done
+ fi
tee "$(results.IMAGE_DIGEST.path)" < /tmp/image-digest
printf '%s' "${PARAM_IMAGE}" | tee "$(results.IMAGE_URL.path)"
volumeMounts: |
1 similar comment
Diff between version 0.9 and 0.10diff --git a/task/buildah/0.9/README.md b/task/buildah/0.10/README.md
index 4ac13c1..e44b395 100644
--- a/task/buildah/0.9/README.md
+++ b/task/buildah/0.10/README.md
@@ -10,7 +10,7 @@ to assemble a container image, then pushes that image to a container registry.
## Install the Task
```
-kubectl apply -f https://api.hub.tekton.dev/v1/resource/tekton/task/buildah/0.9/raw
+kubectl apply -f https://api.hub.tekton.dev/v1/resource/tekton/task/buildah/0.10/raw
```
## Parameters
@@ -32,6 +32,8 @@ kubectl apply -f https://api.hub.tekton.dev/v1/resource/tekton/task/buildah/0.9/
* **PUSH_EXTRA_ARGS**: Extra parameters passed for the push command when
pushing images. WARNING - must be sanitized to avoid command injection
(_default:_ `""`)
+* **ADDITIONAL_TAGS**: Additional tags for the newly built image, like a date or
+ a commit hash. Must be plain text, no commands allowed (_default:_ empty)
* **SKIP_PUSH**: Skip pushing the built image (_default:_ `false`)
* **BUILD_ARGS**: Dockerfile build arguments, array of key=value (_default:_ [""])
diff --git a/task/buildah/0.9/buildah.yaml b/task/buildah/0.10/buildah.yaml
index 91e087b..4927d53 100644
--- a/task/buildah/0.9/buildah.yaml
+++ b/task/buildah/0.10/buildah.yaml
@@ -4,7 +4,7 @@ kind: Task
metadata:
name: buildah
labels:
- app.kubernetes.io/version: "0.9"
+ app.kubernetes.io/version: "0.10"
annotations:
tekton.dev/categories: Image Build
tekton.dev/pipelines.minVersion: "0.50.0"
@@ -53,6 +53,11 @@ spec:
- name: SKIP_PUSH
description: Skip pushing the built image
default: "false"
+ - name: ADDITIONAL_TAGS
+ type: string
+ default: ""
+ description: |
+ Additional tags for pushing the image.
- name: BUILD_ARGS
description: Dockerfile build arguments, array of key=value
type: array
@@ -96,6 +101,8 @@ spec:
value: $(params.PUSH_EXTRA_ARGS)
- name: PARAM_SKIP_PUSH
value: $(params.SKIP_PUSH)
+ - name: PARAMS_ADDITIONAL_TAGS
+ value: $(params.ADDITIONAL_TAGS)
args:
- $(params.BUILD_ARGS[*])
script: |
@@ -117,6 +124,15 @@ spec:
buildah ${CERT_DIR_FLAG} "--storage-driver=${PARAM_STORAGE_DRIVER}" push \
"--tls-verify=${PARAM_TLSVERIFY}" --digestfile /tmp/image-digest ${PARAM_PUSH_EXTRA_ARGS} \
"${PARAM_IMAGE}" "docker://${PARAM_IMAGE}"
+ # push additional tags, if PARAMS_ADDITIONAL_TAGS is not empty
+ # shellcheck disable=SC2046,SC2086
+ if [ -n "${PARAMS_ADDITIONAL_TAGS}" ]; then
+ for tag in ${PARAMS_ADDITIONAL_TAGS};do
+ buildah ${CERT_DIR_FLAG} "--storage-driver=${PARAM_STORAGE_DRIVER}" push \
+ "--tls-verify=${PARAM_TLSVERIFY}" --digestfile /tmp/image-digest ${PARAM_PUSH_EXTRA_ARGS} \
+ "${PARAM_IMAGE}" "docker://${PARAM_IMAGE}":${tag}
+ done
+ fi
tee "$(results.IMAGE_DIGEST.path)" < /tmp/image-digest
printf '%s' "${PARAM_IMAGE}" | tee "$(results.IMAGE_URL.path)"
volumeMounts: |
|
For some reason I cannot sign the CLA, I'll try creating a new PR with my private account. |
Changes
task/buildah/0.10/buildah.yaml: add feature to allow pushing additional tags
This feature allows specifying additional tags like the commit hash or the date or similar, that will be used in addition to "latest".
Please note, those tags need to be strings, not commands like $(date +%Y%m%d).
I have tested this locally and will look into the checklist to see, what I missed.
Discussion see #1373
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
contains
/kind <type>. Valid types are bug, cleanup, design, documentation,feature, flake, misc, question, tep
<kind>/<name>/<version>/name.yamlREADME.mdat<kind>/<name>/<version>/README.mdmetadata.labels-app.kubernetes.io/versionthe same as the<version>of the resourcemetadata.annotationstekton.dev/pipelines.minVersionspec.descriptionfollows the convention