From aeb093240774cddb76984e339feaee1830290376 Mon Sep 17 00:00:00 2001 From: Daniel Mikusa Date: Sun, 29 Oct 2023 22:34:08 -0400 Subject: [PATCH] Adjust behavior of noarch PURLs If a PURL does not have an arch= key, then we will assume it applies to any arch. This would be for JAR files or other non-architecture dependent packages. This behavior is slightly different than when there is no PURL at all. If there is no PURL at all, then we assume x86. This is for backwards compatibility, for buildpacks that do not include PURLs. Signed-off-by: Daniel Mikusa --- buildpack.go | 2 +- buildpack_test.go | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/buildpack.go b/buildpack.go index ed5f675..bd774fd 100644 --- a/buildpack.go +++ b/buildpack.go @@ -560,7 +560,7 @@ func archFromPURL(rawPURL string) (string, error) { return arch[0], nil } - return "amd64", nil + return archFromSystem(), nil } func archFromSystem() string { diff --git a/buildpack_test.go b/buildpack_test.go index a881752..fd7be2a 100644 --- a/buildpack_test.go +++ b/buildpack_test.go @@ -355,6 +355,33 @@ func testBuildpack(t *testing.T, context spec.G, it spec.S) { })) }) + it("filters by arch where arch should match any", func() { + resolver.Dependencies = []libpak.BuildpackDependency{ + { + ID: "test-id-1", + Name: "test-name", + Version: "1.0", + URI: "test-uri", + SHA256: "test-sha256", + Stacks: []string{"test-stack-1", "test-stack-2"}, + PURL: "pkg:generic/spring-cloud-bindings@1.2.3", + }, + } + resolver.StackID = "test-stack-1" + + t.Setenv("BP_ARCH", "arm64") + + Expect(resolver.Resolve("test-id-1", "1.0")).To(Equal(libpak.BuildpackDependency{ + ID: "test-id-1", + Name: "test-name", + Version: "1.0", + URI: "test-uri", + SHA256: "test-sha256", + Stacks: []string{"test-stack-1", "test-stack-2"}, + PURL: "pkg:generic/spring-cloud-bindings@1.2.3", + })) + }) + it("filters by version constraint", func() { resolver.Dependencies = []libpak.BuildpackDependency{ {