From 329e3db8ce9dcd61dbe27e7c10fcc6a425f30573 Mon Sep 17 00:00:00 2001 From: Natalie Arellano Date: Mon, 29 Apr 2024 15:05:03 -0400 Subject: [PATCH] When a buildpack declares distro information, but a base image does not, consider it not a match Signed-off-by: Natalie Arellano --- platform/target_data.go | 5 ++++- platform/target_data_test.go | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/platform/target_data.go b/platform/target_data.go index 26977d676..e88954db3 100644 --- a/platform/target_data.go +++ b/platform/target_data.go @@ -91,9 +91,12 @@ func TargetSatisfiedForBuild(base files.TargetMetadata, module buildpack.TargetM if !matches(base.ArchVariant, module.ArchVariant) { return false } - if base.Distro == nil || len(module.Distros) == 0 { + if len(module.Distros) == 0 { return true } + if base.Distro == nil { + return false + } foundMatchingDist := false for _, modDist := range module.Distros { if matches(base.Distro.Name, modDist.Name) && matches(base.Distro.Version, modDist.Version) { diff --git a/platform/target_data_test.go b/platform/target_data_test.go index cc9bd5dce..2742f8f46 100644 --- a/platform/target_data_test.go +++ b/platform/target_data_test.go @@ -41,14 +41,14 @@ func testTargetData(t *testing.T, when spec.G, it spec.S) { }) }) - when("has extra information", func() { - it("matches", func() { + when("has distro information", func() { + it("does not match", func() { h.AssertEq(t, platform.TargetSatisfiedForBuild(baseTarget, buildpack.TargetMetadata{OS: baseTarget.OS, Arch: baseTarget.Arch, ArchVariant: "MMX"}), true) h.AssertEq(t, platform.TargetSatisfiedForBuild(baseTarget, buildpack.TargetMetadata{ OS: baseTarget.OS, Arch: baseTarget.Arch, Distros: []buildpack.OSDistro{{Name: "a", Version: "2"}}, - }), true) + }), false) }) }) })