Skip to content

Commit

Permalink
When a buildpack declares distro information, but a base image does n…
Browse files Browse the repository at this point in the history
…ot, (#1348)

consider it not a match

Signed-off-by: Natalie Arellano <[email protected]>
  • Loading branch information
natalieparellano authored May 1, 2024
1 parent 13d3691 commit 44b7041
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion platform/target_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions platform/target_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
})
Expand Down

0 comments on commit 44b7041

Please sign in to comment.