Closed edmorley closed 3 months ago
Thanks @edmorley - this is indeed a bug. It looks like we set the label constant incorrectly here: https://github.com/buildpacks/lifecycle/blob/435d226f1ed54b0bec806716ba79e14a2a093736/platform/run_image.go#L19-L22
We will probably want to backport this fix for this to 0.17.x for the reasons described in https://github.com/buildpacks/lifecycle/pull/1309#issuecomment-1988929012
It looks like we set the label constant incorrectly here:
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: https://github.com/search?q=repo%3Abuildpacks%2Flifecycle+%22io.buildpacks.distro%22+path%3A%2F%5Ephase%5C%2F%2F&type=code
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 :-)).
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-dataReproduction
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.