Skip to content

Commit

Permalink
Add KO_EXTRA_ARGS
Browse files Browse the repository at this point in the history
Add support for passing extra args to `ko` and move the existing
args `--preserve-import-paths` to be the default for the publish task.
This means we no longer need the `release` command in the installer
script as the `--preserve-import-paths` arg will be passed in from
the pipeline.

This change means that the pipeline can now control `ko` settings and
change the default path based on the registry.
  • Loading branch information
AlanGreene authored and tekton-robot committed Sep 25, 2024
1 parent cc33c8a commit 619cc10
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 20 deletions.
8 changes: 0 additions & 8 deletions docs/dev/installer.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ It covers the following topics:
- [Install ingress](#install-ingress)
- [Uninstall command](#uninstall-command)
- [Build command](#build-command)
- [Release command](#release-command)
- [Platform support](#platform-support)

## Before you begin
Expand Down Expand Up @@ -55,7 +54,6 @@ Accepted commands:
install|i Installs the dashboard
uninstall|u Uninstalls the dashboard
build|b Builds the manifests and dashboard docker image
release|r Builds the manifests and dashboard docker image for release

Accepted options:
[--debug] Prints additional messages in the console
Expand Down Expand Up @@ -170,12 +168,6 @@ This will NOT deploy the resulting manifest in the target cluster but will build

The `build` command is useful when you want to ensure everything builds correctly without altering the current deployment. It can help verifying the generated manifests are correct when a change was made in the base or overlays used by `kustomize` too.

## Release command

This command is essentially the same as the [build command](#build-command) but adds the `--preserve-import-paths` option when invoking `ko`.

This is needed to generate the correct docker image name in the manifests when cutting a release.

## Platform support

Official Dashboard releases since v0.12.0 provide multi-platform images supporting the following:
Expand Down
10 changes: 4 additions & 6 deletions scripts/installer
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,6 @@ help () {
echo -e "\tinstall|i\t\t\t\tInstalls the dashboard"
echo -e "\tuninstall|u\t\t\t\tUninstalls the dashboard"
echo -e "\tbuild|b\t\t\t\t\tBuilds the manifests and dashboard docker image"
echo -e "\trelease|r\t\t\t\tBuilds the manifests and dashboard docker image for release"
echo -e ""
echo -e "Accepted options:"
echo -e "\t[--debug]\t\t\t\tPrints additional messages in the console"
Expand Down Expand Up @@ -444,11 +443,6 @@ case $1 in
ACTION="build"
shift
;;
'release'|r)
KO_RESOLVE_OPTIONS="$KO_RESOLVE_OPTIONS --preserve-import-paths"
ACTION="build"
shift
;;
*)
ACTION="build"
;;
Expand Down Expand Up @@ -539,6 +533,10 @@ while [[ $# -gt 0 ]]; do
shift
KO_RESOLVE_OPTIONS="$KO_RESOLVE_OPTIONS -t ${1}"
;;
'--preserve-import-paths')
shift
KO_RESOLVE_OPTIONS="$KO_RESOLVE_OPTIONS --preserve-import-paths"
;;
*)
echo "ERROR: Unknown option $1"
help
Expand Down
32 changes: 26 additions & 6 deletions tekton/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ spec:
- name: images
description: List of cmd/* paths to be published as images
default: "dashboard"
- name: koExtraArgs
description: Extra args to be passed to ko
default: "--preserve-import-paths"
- name: versionTag
description: The vX.Y.Z version that the artifacts should be tagged with (including `v`)
- name: imageRegistry
Expand Down Expand Up @@ -70,6 +73,8 @@ spec:
value: "$(params.imageRegistryRegions)"
- name: OUTPUT_RELEASE_DIR
value: "$(workspaces.output.path)/$(params.versionTag)"
- name: KO_EXTRA_ARGS
value: "$(params.koExtraArgs)"
results:
# IMAGES result is picked up by Tekton Chains to sign the release.
# See https://github.com/tektoncd/plumbing/blob/main/docs/signing.md for more info.
Expand Down Expand Up @@ -128,18 +133,32 @@ spec:
# build manifests for installer
KO_RESOLVE_IMAGE_LABEL="--image-label=org.opencontainers.image.source=https://$(params.package)"
kustomize build overlays/installer/read-only --load-restrictor LoadRestrictionsNone | ko resolve ${KO_RESOLVE_IMAGE_LABEL} --platform=$(params.platforms) --preserve-import-paths -t $(params.versionTag) -f - > $OUTPUT_RELEASE_DIR/installer-release.yaml
kustomize build overlays/installer/read-write --load-restrictor LoadRestrictionsNone | ko resolve ${KO_RESOLVE_IMAGE_LABEL} --platform=$(params.platforms) --preserve-import-paths -t $(params.versionTag) -f - > $OUTPUT_RELEASE_DIR/installer-release-full.yaml
kustomize build overlays/installer/read-only --load-restrictor LoadRestrictionsNone | ko resolve ${KO_RESOLVE_IMAGE_LABEL} --platform=$(params.platforms) ${KO_EXTRA_ARGS} -t $(params.versionTag) -f - > $OUTPUT_RELEASE_DIR/installer-release.yaml
kustomize build overlays/installer/read-write --load-restrictor LoadRestrictionsNone | ko resolve ${KO_RESOLVE_IMAGE_LABEL} --platform=$(params.platforms) ${KO_EXTRA_ARGS} -t $(params.versionTag) -f - > $OUTPUT_RELEASE_DIR/installer-release-full.yaml
# build pre configured manifests
./scripts/installer release --debug --platform $(params.platforms) --tag $(params.versionTag) --output $OUTPUT_RELEASE_DIR/release.yaml
./scripts/installer release --debug --read-write --platform $(params.platforms) --tag $(params.versionTag) --output $OUTPUT_RELEASE_DIR/release-full.yaml
./scripts/installer build --debug --platform $(params.platforms) --tag $(params.versionTag) --output $OUTPUT_RELEASE_DIR/release.yaml ${KO_EXTRA_ARGS}
./scripts/installer build --debug --read-write --platform $(params.platforms) --tag $(params.versionTag) --output $OUTPUT_RELEASE_DIR/release-full.yaml ${KO_EXTRA_ARGS}
- name: koparse
image: gcr.io/tekton-releases/dogfooding/koparse:v20240923-1c3aa3eee7@sha256:ae363d70e3c2fb75e96aaeb561dcea20383c27a47f0266c8179bbb72b89c2430
script: |
set -ex
# Find "--preserve-import-paths" in a list of args
function find_preserve_import_path() {
for arg in $@; do
if [[ "$arg" == "--preserve-import-paths" ]]; then
return 0
fi
done
return 1
}
# If "--preserve-import-paths" is used, include "package" in the expected path
find_preserve_import_path \
$(echo $KO_EXTRA_ARGS) && \
PRESERVE_IMPORT_PATH="--preserve-path" || \
PRESERVE_IMPORT_PATH="--no-preserve-path"
for cmd in $(params.images)
do
IMAGES="${IMAGES} $(params.package)/cmd/${cmd}:$(params.versionTag)"
Expand All @@ -150,7 +169,8 @@ spec:
--path $OUTPUT_RELEASE_DIR/release.yaml \
--base $(params.package) \
--container-registry ${CONTAINER_REGISTRY} \
--images ${IMAGES} > /workspace/built_images
--images ${IMAGES} \
${PRESERVE_IMPORT_PATH} > /workspace/built_images
- name: tag-images
image: gcr.io/go-containerregistry/crane:debug@sha256:ff0e08eeae8097d28b2381c7f7123bf542757abc68d11bff58fb882b72843785
Expand Down
5 changes: 5 additions & 0 deletions tekton/release-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ spec:
- name: platforms
description: Platforms to publish for the images (e.g. linux/amd64,linux/arm64)
default: linux/amd64,linux/arm,linux/arm64,linux/s390x,linux/ppc64le
- name: koExtraArgs
description: Extra args to be passed to ko
default: "--preserve-import-paths"
- name: serviceAccountPath
description: The path to the service account file within the release-secret workspace
- name: serviceAccountImagesPath
Expand Down Expand Up @@ -127,6 +130,8 @@ spec:
value: $(params.serviceAccountImagesPath)
- name: platforms
value: $(params.platforms)
- name: koExtraArgs
value: $(params.koExtraArgs)
workspaces:
- name: source
workspace: workarea
Expand Down

0 comments on commit 619cc10

Please sign in to comment.