Closed edmorley closed 2 months ago
@edmorley if we fix https://github.com/buildpacks/lifecycle/issues/1336 should we not expect that the base distro is never (or rarely) nil? (I am not sure that we want to fail for mismatched distros if one isn't specified)
@natalieparellano Yeah once #1336 is fixed this issue should only affect:
(I am not sure that we want to fail for mismatched distros if one isn't specified)
So I think if the buildpack says "I'm only supported on X", then lifecycle
shouldn't guess and pass detection if it can't figure out the distro name/version.
Ultimately if the buildpack author wanted to match against anything, then it feels like they should/would omit the distro name/version?
Summary
The Buildpack API 0.10 spec says:
(https://github.com/buildpacks/spec/blob/buildpack/v0.10/buildpack.md#targets)
As such, if a buildpack's
buildpack.toml
contains:...then I would expect the buildpack to only pass detection if the run image's distro name was "ubuntu" and version was "123".
However, it seems that if the distro name/version could not be determined by
lifecycle
(for example, the run image doesn't have theio.buildpacks.base.distro.*
Docker labels set and the/etc/os-release
fallback isn't available or is broken), thenlifecycle
ignores the[[targets.distros]]
requirements and instead matches against any distro.The cause of this appears to be the
base.Distro == nil
part of this conditional: https://github.com/buildpacks/lifecycle/blob/435d226f1ed54b0bec806716ba79e14a2a093736/platform/target_data.go#L94-L96Reproduction
Steps
pack buildpack new testcase-buildpack-targets --api 0.10 --targets "linux/amd64"
echo -e '\n[[targets.distros]]\nname = "ubuntu"\nversion = "123"' >> testcase-buildpack-targets/buildpack.toml
pack build --builder heroku/builder:22 --run-image heroku/heroku:22-cnb.v122 --buildpack testcase-buildpack-targets/ --path testcase-buildpack-targets/ testapp --verbose
Current behavior
Buildpack detection unexpectedly passes:
...even though the buildpack declares that it only supports:
...and the run image's Ubuntu version is not "123".
Expected behavior
I would expect buildpack detection to fail, like how it fails if I use a newer version of our run image (by omitting the
--run-image heroku/heroku:22-cnb.v122
argument) that has the relevantio.buildpacks.base.distro.*
Docker labels set:Context
lifecycle version
0.19.3
platform version(s)
The build is using Platform API 0.12 and Buildpack API 0.10.