diff --git a/docs/dev/installer.md b/docs/dev/installer.md index 037dabab5..1ff001d7c 100644 --- a/docs/dev/installer.md +++ b/docs/dev/installer.md @@ -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 @@ -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 @@ -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: diff --git a/scripts/installer b/scripts/installer index 4d4bcdb1d..661e66339 100755 --- a/scripts/installer +++ b/scripts/installer @@ -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" @@ -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" ;; @@ -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 diff --git a/tekton/publish.yaml b/tekton/publish.yaml index 696021c8f..2fe4decaa 100644 --- a/tekton/publish.yaml +++ b/tekton/publish.yaml @@ -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 @@ -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. @@ -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)" @@ -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 diff --git a/tekton/release-pipeline.yaml b/tekton/release-pipeline.yaml index 937d55deb..c8cdb4298 100644 --- a/tekton/release-pipeline.yaml +++ b/tekton/release-pipeline.yaml @@ -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 @@ -127,6 +130,8 @@ spec: value: $(params.serviceAccountImagesPath) - name: platforms value: $(params.platforms) + - name: koExtraArgs + value: $(params.koExtraArgs) workspaces: - name: source workspace: workarea