-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CNB_TARGET_DISTRO_NAME
and CNB_TARGET_DISTRO_VERSION
not set correctly in buildpack env
#1324
Comments
Thanks @edmorley - this is indeed a bug. It looks like we set the label constant incorrectly here: lifecycle/platform/run_image.go Lines 19 to 22 in 435d226
|
We will probably want to backport this fix for this to 0.17.x for the reasons described in #1309 (comment) |
Ah good spot! I was going to ask how we might test the fix, but it seems there are tests, just that they also test the wrong label - so we can update those to get coverage: I've also GitHub code searched to check nothing else (spec, docs, rfcs etc) is using the wrong label - and the rest looks fine. I can open a PR for this in a couple of hours after I've eaten (unless someone else beats me to it, which is fine too :-)). |
The spec and docs say that the run image distro and version should be specified via the Docker image labels `io.buildpacks.base.distro.name` and `io.buildpacks.base.distro.version`. See: https://github.com/buildpacks/spec/blob/buildpack/v0.10/platform.md#target-data However, until now the lifecycle implementation was checking for label names that were missing the `.base` substring from the name. This causes distro name/version `buildpack.toml` target detection to fail, as well as the env vars `CNB_TARGET_DISTRO_NAME` and `CNB_TARGET_DISTRO_VERSION` not to be set correctly in the buildpack environment. Fixes buildpacks#1324.
The spec and docs say that the run image distro and version should be specified via the Docker image labels `io.buildpacks.base.distro.name` and `io.buildpacks.base.distro.version`. See: https://github.com/buildpacks/spec/blob/buildpack/v0.10/platform.md#target-data However, until now the lifecycle implementation was checking for label names that were missing the `.base` substring from the name. This causes distro name/version `buildpack.toml` target detection to fail, as well as the env vars `CNB_TARGET_DISTRO_NAME` and `CNB_TARGET_DISTRO_VERSION` not to be set correctly in the buildpack environment. Fixes buildpacks#1324. Signed-off-by: Ed Morley <501702+edmorley@users.noreply.github.com>
The spec and docs say that the run image distro and version should be specified via the Docker image labels `io.buildpacks.base.distro.name` and `io.buildpacks.base.distro.version`. See: https://github.com/buildpacks/spec/blob/buildpack/v0.10/platform.md#target-data However, until now the lifecycle implementation was checking for label names that were missing the `.base` substring from the name. This causes distro name/version `buildpack.toml` target detection to fail, as well as the env vars `CNB_TARGET_DISTRO_NAME` and `CNB_TARGET_DISTRO_VERSION` not to be set correctly in the buildpack environment. Fixes #1324. Signed-off-by: Ed Morley <501702+edmorley@users.noreply.github.com>
The spec and docs say that the run image distro and version should be specified via the Docker image labels `io.buildpacks.base.distro.name` and `io.buildpacks.base.distro.version`. See: https://github.com/buildpacks/spec/blob/buildpack/v0.10/platform.md#target-data However, until now the lifecycle implementation was checking for label names that were missing the `.base` substring from the name. This causes distro name/version `buildpack.toml` target detection to fail, as well as the env vars `CNB_TARGET_DISTRO_NAME` and `CNB_TARGET_DISTRO_VERSION` not to be set correctly in the buildpack environment. Fixes #1324. Signed-off-by: Ed Morley <501702+edmorley@users.noreply.github.com>
Summary
The Buildpack API 0.10 spec says:
(https://github.com/buildpacks/spec/blob/buildpack/v0.10/buildpack.md#targets)
However, these env vars aren't being set for us, even though the relevant
io.buildpacks.base.distro.*
labels are set on the run (and build) images per:https://github.com/buildpacks/spec/blob/buildpack/v0.10/platform.md#target-data
Reproduction
Steps
pack buildpack new testcase-target-env-vars --api 0.10 --targets "linux/amd64"
sed -i 's/exit 0/printenv | grep CNB_TARGET | sort/' testcase-target-env-vars/bin/build
pack build --builder heroku/builder:22 --buildpack testcase-target-env-vars/ --path testcase-target-env-vars/ testapp --verbose
docker inspect heroku/heroku:22-cnb | jq '.[0].Config.Labels'
Current behavior
The
CNB_TARGET_DISTRO_NAME
andCNB_TARGET_DISTRO_VERSION
env vars are not set correctly in the buildpack env:Note: The analyser phase says
"target":{"os":"linux","arch":"amd64"}
when I presume there should be keys in there for distro?Checking our run image, it does have the required
io.buildpacks.base.distro.*
labels set:Expected behavior
For the
CNB_TARGET_DISTRO_*
env vars to be set, eg:Context
lifecycle version
0.19.0
platform version(s)
The build is using Platform API 0.12 and Buildpack API 0.10.
The text was updated successfully, but these errors were encountered: