Skip to content

Commit 27a76ca

Browse files
afrittolitekton-robot
authored andcommitted
Add KO_EXTRA_ARGS
Add the ability to add ko extra args and move the existing arg --preserve-import-paths to be a default for the task. This way the pipeline run can control settings and change the default path based on the registry, as well as control other ko settings. Signed-off-by: Andrea Frittoli <[email protected]>
1 parent cdf169a commit 27a76ca

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

tekton/publish.yaml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ spec:
1212
- name: images
1313
description: List of cmd/* paths to be published as images
1414
default: "controller webhook entrypoint nop workingdirinit resolvers sidecarlogresults events"
15+
- name: koExtraArgs
16+
description: Extra args to be passed to ko
17+
default: "--preserve-import-paths"
1518
- name: versionTag
1619
description: The vX.Y.Z version that the artifacts should be tagged with (including `v`)
1720
- name: imageRegistry
@@ -59,6 +62,8 @@ spec:
5962
value: "$(params.imageRegistryRegions)"
6063
- name: OUTPUT_RELEASE_DIR
6164
value: "$(workspaces.output.path)/$(params.versionTag)"
65+
- name: KO_EXTRA_ARGS
66+
value: "$(params.koExtraArgs)"
6267
results:
6368
# IMAGES result is picked up by Tekton Chains to sign the release.
6469
# See https://github.com/tektoncd/plumbing/blob/main/docs/signing.md for more info.
@@ -164,15 +169,20 @@ spec:
164169
# The real "tagging" will happen with the "create-release" pipeline.
165170
git tag $(params.versionTag)
166171
167-
ko resolve --platform=$(params.platforms) --preserve-import-paths -t $(params.versionTag) -R -f ${PROJECT_ROOT}/config/ > $OUTPUT_RELEASE_DIR/release.yaml
172+
ko resolve \
173+
--image-label=org.opencontainers.image.source=https://$(params.package) \
174+
--platform=$(params.platforms) \
175+
-t $(params.versionTag) \
176+
-R ${KO_EXTRA_ARGS} \
177+
-f ${PROJECT_ROOT}/config/ > $OUTPUT_RELEASE_DIR/release.yaml
168178
# Publish images and create release.notags.yaml
169179
# This is useful if your container runtime doesn't support the `image-reference:tag@digest` notation
170180
# This is currently the case for `cri-o` (and most likely others)
171181
ko resolve \
172182
--image-label=org.opencontainers.image.source=https://$(params.package) \
173183
--platform=$(params.platforms) \
174-
--preserve-import-paths \
175-
-R -f ${PROJECT_ROOT}/config/ > $OUTPUT_RELEASE_DIR/release.notags.yaml
184+
-R ${KO_EXTRA_ARGS} \
185+
-f ${PROJECT_ROOT}/config/ > $OUTPUT_RELEASE_DIR/release.notags.yaml
176186
177187
# Rewrite "devel" to params.versionTag
178188
sed -i -e 's/\(pipeline.tekton.dev\/release\): "devel"/\1: "$(params.versionTag)"/g' -e 's/\(app.kubernetes.io\/version\): "devel"/\1: "$(params.versionTag)"/g' -e 's/\(version\): "devel"/\1: "$(params.versionTag)"/g' ${OUTPUT_RELEASE_DIR}/release.yaml

tekton/release-pipeline.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ spec:
3939
can differ from buildPlatforms due to the fact that a windows-compatible base image
4040
is constructed for the publishing phase.
4141
default: linux/amd64,linux/arm,linux/arm64,linux/s390x,linux/ppc64le,windows/amd64
42+
- name: koExtraArgs
43+
description: Extra args to be passed to ko
44+
default: "--preserve-import-paths"
4245
- name: serviceAccountPath
4346
description: The path to the service account file within the release-secret workspace
4447
- name: serviceAccountImagesPath
@@ -174,6 +177,8 @@ spec:
174177
value: $(params.serviceAccountImagesPath)
175178
- name: platforms
176179
value: $(params.publishPlatforms)
180+
- name: koExtraArgs
181+
value: $(params.koExtraArgs)
177182
workspaces:
178183
- name: source
179184
workspace: workarea

0 commit comments

Comments
 (0)