Skip to content

Commit

Permalink
Allow to specify build platform for test images (#4763)
Browse files Browse the repository at this point in the history
By default if no platform is specified, ko uses `linux/amd64`,
which breaks the test images usage  for other architectures.
Using PLATFORM env variable provides ability to specify for which
platform do the build, for instance, linux/arm64 or linux/s390x.

Signed-off-by: Yulia Gaponenko <[email protected]>
  • Loading branch information
barthy1 authored Jan 22, 2021
1 parent 7123f45 commit ebd5b0f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ build and push the test images used by the e2e tests. It requires:
[authenticated with your `KO_DOCKER_REPO`](https://github.com/knative/serving/blob/master/DEVELOPMENT.md#environment-setup)
- [`docker`](https://docs.docker.com/install/) to be installed

`PLATFORM` environment variable is optional. If it is specified, test images
will be built for specific hardware architecture, according to its value
(for instance,`linux/arm64`).

To run the script for all end to end test images:

```bash
Expand Down
10 changes: 9 additions & 1 deletion test/upload-test-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,17 @@ function upload_test_images() {
tag_option="--tags $docker_tag,latest"
fi

# If PLATFORM environment variable is specified, then images will be built for
# specific hardware architecture.
# Example of the variable values - "linux/arm64", "linux/s390x".
local platform=""
if [ -n "${PLATFORM}" ]; then
platform="--platform ${PLATFORM}"
fi

# ko resolve is being used for the side-effect of publishing images,
# so the resulting yaml produced is ignored.
ko resolve ${tag_option} -RBf "${image_dir}" > /dev/null
ko resolve ${platform} ${tag_option} -RBf "${image_dir}" > /dev/null
}

: ${KO_DOCKER_REPO:?"You must set 'KO_DOCKER_REPO', see DEVELOPMENT.md"}
Expand Down

0 comments on commit ebd5b0f

Please sign in to comment.