From 0d4327bc69b33523f5ad049a682b9b0c1fd60981 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Fri, 20 Feb 2026 20:46:55 +0100 Subject: [PATCH 1/9] refactor: cleanup SBOMGenerator --- build_test.go | 5 ++- .../fakes/sbom_generator.go | 0 pkg/installers/miniconda/build.go | 4 -- pkg/installers/miniconda/build_test.go | 6 ++- pkg/installers/miniconda/detect_test.go | 1 + pkg/installers/pip/build.go | 4 -- pkg/installers/pip/build_test.go | 6 ++- pkg/installers/pip/fakes/sbom_generator.go | 40 ------------------ pkg/installers/pipenv/build.go | 4 -- pkg/installers/pipenv/build_test.go | 5 ++- pkg/installers/pipenv/fakes/sbom_generator.go | 40 ------------------ pkg/installers/pixi/build.go | 4 -- pkg/installers/pixi/build_test.go | 6 ++- pkg/installers/pixi/fakes/sbom_generator.go | 41 ------------------- pkg/installers/poetry/build_test.go | 6 ++- pkg/installers/poetry/fakes/sbom_generator.go | 40 ------------------ pkg/installers/uv/build.go | 4 -- pkg/installers/uv/build_test.go | 6 ++- pkg/installers/uv/fakes/sbom_generator.go | 41 ------------------- 19 files changed, 27 insertions(+), 236 deletions(-) rename pkg/installers/{miniconda => common}/fakes/sbom_generator.go (100%) delete mode 100644 pkg/installers/pip/fakes/sbom_generator.go delete mode 100644 pkg/installers/pipenv/fakes/sbom_generator.go delete mode 100644 pkg/installers/pixi/fakes/sbom_generator.go delete mode 100644 pkg/installers/poetry/fakes/sbom_generator.go delete mode 100644 pkg/installers/uv/fakes/sbom_generator.go diff --git a/build_test.go b/build_test.go index 45ce1bb..066449b 100644 --- a/build_test.go +++ b/build_test.go @@ -23,6 +23,7 @@ import ( pythoninstallers "github.com/paketo-buildpacks/python-installers" pkgcommon "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + commonfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/fakes" miniconda "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda" minicondafakes "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda/fakes" pip "github.com/paketo-buildpacks/python-installers/pkg/installers/pip" @@ -59,7 +60,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { buildContext packit.BuildContext // common - sbomGenerator *pipfakes.SBOMGenerator + sbomGenerator *commonfakes.SBOMGenerator // dependencyManager *pipfakes.DependencyManager // conda @@ -102,7 +103,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { buffer = bytes.NewBuffer(nil) logger = scribe.NewEmitter(buffer) - sbomGenerator = &pipfakes.SBOMGenerator{} + sbomGenerator = &commonfakes.SBOMGenerator{} sbomGenerator.GenerateFromDependencyCall.Returns.SBOM = sbom.SBOM{} // miniconda diff --git a/pkg/installers/miniconda/fakes/sbom_generator.go b/pkg/installers/common/fakes/sbom_generator.go similarity index 100% rename from pkg/installers/miniconda/fakes/sbom_generator.go rename to pkg/installers/common/fakes/sbom_generator.go diff --git a/pkg/installers/miniconda/build.go b/pkg/installers/miniconda/build.go index f07044a..e2326d0 100644 --- a/pkg/installers/miniconda/build.go +++ b/pkg/installers/miniconda/build.go @@ -35,10 +35,6 @@ type Runner interface { Run(runPath, layerPath string) error } -type SBOMGenerator interface { - GenerateFromDependency(dependency postal.Dependency, dir string) (sbom.SBOM, error) -} - func GetEnvOrDefault(key, defaultValue string) string { value, exists := os.LookupEnv(key) if !exists { diff --git a/pkg/installers/miniconda/build_test.go b/pkg/installers/miniconda/build_test.go index 0784371..3a245c2 100644 --- a/pkg/installers/miniconda/build_test.go +++ b/pkg/installers/miniconda/build_test.go @@ -15,6 +15,8 @@ import ( "github.com/paketo-buildpacks/packit/v2/chronos" pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + commonfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/fakes" + "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda" "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda/fakes" @@ -39,7 +41,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { dependencyManager *fakes.DependencyManager runner *fakes.Runner - sbomGenerator *fakes.SBOMGenerator + sbomGenerator *commonfakes.SBOMGenerator build packit.BuildFunc buildContext packit.BuildContext @@ -81,7 +83,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { runner = &fakes.Runner{} // Syft SBOM - sbomGenerator = &fakes.SBOMGenerator{} + sbomGenerator = &commonfakes.SBOMGenerator{} sbomGenerator.GenerateFromDependencyCall.Returns.SBOM = sbom.SBOM{} buffer = bytes.NewBuffer(nil) diff --git a/pkg/installers/miniconda/detect_test.go b/pkg/installers/miniconda/detect_test.go index 47622cd..6ae9e06 100644 --- a/pkg/installers/miniconda/detect_test.go +++ b/pkg/installers/miniconda/detect_test.go @@ -11,6 +11,7 @@ import ( "github.com/sclevine/spec" pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda" . "github.com/onsi/gomega" diff --git a/pkg/installers/pip/build.go b/pkg/installers/pip/build.go index b90cffe..425a1c4 100644 --- a/pkg/installers/pip/build.go +++ b/pkg/installers/pip/build.go @@ -42,10 +42,6 @@ type SitePackageProcess interface { Execute(targetLayerPath string) (string, error) } -type SBOMGenerator interface { - GenerateFromDependency(dependency postal.Dependency, dir string) (sbom.SBOM, error) -} - // PipBuildParameters encapsulates the pip specific parameters for the // Build function type PipBuildParameters struct { diff --git a/pkg/installers/pip/build_test.go b/pkg/installers/pip/build_test.go index 2e0ebbf..a819057 100644 --- a/pkg/installers/pip/build_test.go +++ b/pkg/installers/pip/build_test.go @@ -23,6 +23,8 @@ import ( "github.com/sclevine/spec" pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + commonfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/fakes" + "github.com/paketo-buildpacks/python-installers/pkg/installers/pip" "github.com/paketo-buildpacks/python-installers/pkg/installers/pip/fakes" @@ -39,7 +41,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { dependencyManager *fakes.DependencyManager installProcess *fakes.InstallProcess sitePackageProcess *fakes.SitePackageProcess - sbomGenerator *fakes.SBOMGenerator + sbomGenerator *commonfakes.SBOMGenerator logger scribe.Emitter @@ -95,7 +97,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { sitePackageProcess.ExecuteCall.Returns.String = filepath.Join(layersDir, "pip", "lib", "python1.23", "site-packages") // Syft SBOM - sbomGenerator = &fakes.SBOMGenerator{} + sbomGenerator = &commonfakes.SBOMGenerator{} sbomGenerator.GenerateFromDependencyCall.Returns.SBOM = sbom.SBOM{} buffer = bytes.NewBuffer(nil) diff --git a/pkg/installers/pip/fakes/sbom_generator.go b/pkg/installers/pip/fakes/sbom_generator.go deleted file mode 100644 index a0deccf..0000000 --- a/pkg/installers/pip/fakes/sbom_generator.go +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2013-Present CloudFoundry.org Foundation, Inc. All Rights Reserved. -// -// SPDX-License-Identifier: Apache-2.0 - -package fakes - -import ( - "sync" - - "github.com/paketo-buildpacks/packit/v2/postal" - "github.com/paketo-buildpacks/packit/v2/sbom" -) - -type SBOMGenerator struct { - GenerateFromDependencyCall struct { - mutex sync.Mutex - CallCount int - Receives struct { - Dependency postal.Dependency - Dir string - } - Returns struct { - SBOM sbom.SBOM - Error error - } - Stub func(postal.Dependency, string) (sbom.SBOM, error) - } -} - -func (f *SBOMGenerator) GenerateFromDependency(param1 postal.Dependency, param2 string) (sbom.SBOM, error) { - f.GenerateFromDependencyCall.mutex.Lock() - defer f.GenerateFromDependencyCall.mutex.Unlock() - f.GenerateFromDependencyCall.CallCount++ - f.GenerateFromDependencyCall.Receives.Dependency = param1 - f.GenerateFromDependencyCall.Receives.Dir = param2 - if f.GenerateFromDependencyCall.Stub != nil { - return f.GenerateFromDependencyCall.Stub(param1, param2) - } - return f.GenerateFromDependencyCall.Returns.SBOM, f.GenerateFromDependencyCall.Returns.Error -} diff --git a/pkg/installers/pipenv/build.go b/pkg/installers/pipenv/build.go index 85adddc..67ee8f7 100644 --- a/pkg/installers/pipenv/build.go +++ b/pkg/installers/pipenv/build.go @@ -40,10 +40,6 @@ type SitePackageProcess interface { Execute(targetLayerPath string) (string, error) } -type SBOMGenerator interface { - GenerateFromDependency(dependency postal.Dependency, dir string) (sbom.SBOM, error) -} - // PipEnvBuildParameters encapsulates the pip specific parameters for the // Build function type PipEnvBuildParameters struct { diff --git a/pkg/installers/pipenv/build_test.go b/pkg/installers/pipenv/build_test.go index e23e418..e4a7f81 100644 --- a/pkg/installers/pipenv/build_test.go +++ b/pkg/installers/pipenv/build_test.go @@ -23,6 +23,7 @@ import ( "github.com/sclevine/spec" pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + commonfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/pipenv" "github.com/paketo-buildpacks/python-installers/pkg/installers/pipenv/fakes" @@ -39,7 +40,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { dependencyManager *fakes.DependencyManager installProcess *fakes.InstallProcess siteProcess *fakes.SitePackageProcess - sbomGenerator *fakes.SBOMGenerator + sbomGenerator *commonfakes.SBOMGenerator buffer *bytes.Buffer @@ -82,7 +83,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { siteProcess = &fakes.SitePackageProcess{} // Syft SBOM - sbomGenerator = &fakes.SBOMGenerator{} + sbomGenerator = &commonfakes.SBOMGenerator{} sbomGenerator.GenerateFromDependencyCall.Returns.SBOM = sbom.SBOM{} buffer = bytes.NewBuffer(nil) diff --git a/pkg/installers/pipenv/fakes/sbom_generator.go b/pkg/installers/pipenv/fakes/sbom_generator.go deleted file mode 100644 index a0deccf..0000000 --- a/pkg/installers/pipenv/fakes/sbom_generator.go +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2013-Present CloudFoundry.org Foundation, Inc. All Rights Reserved. -// -// SPDX-License-Identifier: Apache-2.0 - -package fakes - -import ( - "sync" - - "github.com/paketo-buildpacks/packit/v2/postal" - "github.com/paketo-buildpacks/packit/v2/sbom" -) - -type SBOMGenerator struct { - GenerateFromDependencyCall struct { - mutex sync.Mutex - CallCount int - Receives struct { - Dependency postal.Dependency - Dir string - } - Returns struct { - SBOM sbom.SBOM - Error error - } - Stub func(postal.Dependency, string) (sbom.SBOM, error) - } -} - -func (f *SBOMGenerator) GenerateFromDependency(param1 postal.Dependency, param2 string) (sbom.SBOM, error) { - f.GenerateFromDependencyCall.mutex.Lock() - defer f.GenerateFromDependencyCall.mutex.Unlock() - f.GenerateFromDependencyCall.CallCount++ - f.GenerateFromDependencyCall.Receives.Dependency = param1 - f.GenerateFromDependencyCall.Receives.Dir = param2 - if f.GenerateFromDependencyCall.Stub != nil { - return f.GenerateFromDependencyCall.Stub(param1, param2) - } - return f.GenerateFromDependencyCall.Returns.SBOM, f.GenerateFromDependencyCall.Returns.Error -} diff --git a/pkg/installers/pixi/build.go b/pkg/installers/pixi/build.go index db82246..ef38b2f 100644 --- a/pkg/installers/pixi/build.go +++ b/pkg/installers/pixi/build.go @@ -35,10 +35,6 @@ type InstallProcess interface { Execute(sourcePath, targetLayerPath, dependencyName string) error } -type SBOMGenerator interface { - GenerateFromDependency(dependency postal.Dependency, dir string) (sbom.SBOM, error) -} - // PixiBuildParameters encapsulates the pixi specific parameters for the // Build function type PixiBuildParameters struct { diff --git a/pkg/installers/pixi/build_test.go b/pkg/installers/pixi/build_test.go index 45721b9..0bd66dd 100644 --- a/pkg/installers/pixi/build_test.go +++ b/pkg/installers/pixi/build_test.go @@ -16,6 +16,8 @@ import ( "github.com/paketo-buildpacks/packit/v2/chronos" pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + commonfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/fakes" + "github.com/paketo-buildpacks/python-installers/pkg/installers/pixi" "github.com/paketo-buildpacks/python-installers/pkg/installers/pixi/fakes" @@ -40,7 +42,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { dependencyManager *fakes.DependencyManager installProcess *fakes.InstallProcess - sbomGenerator *fakes.SBOMGenerator + sbomGenerator *commonfakes.SBOMGenerator build packit.BuildFunc buildContext packit.BuildContext @@ -80,7 +82,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { } // Syft SBOM - sbomGenerator = &fakes.SBOMGenerator{} + sbomGenerator = &commonfakes.SBOMGenerator{} sbomGenerator.GenerateFromDependencyCall.Returns.SBOM = sbom.SBOM{} installProcess = &fakes.InstallProcess{} diff --git a/pkg/installers/pixi/fakes/sbom_generator.go b/pkg/installers/pixi/fakes/sbom_generator.go deleted file mode 100644 index 90398d4..0000000 --- a/pkg/installers/pixi/fakes/sbom_generator.go +++ /dev/null @@ -1,41 +0,0 @@ -// SPDX-FileCopyrightText: © 2026 Idiap Research Institute -// SPDX-FileContributor: Samuel Gaist -// -// SPDX-License-Identifier: Apache-2.0 - -package fakes - -import ( - "sync" - - "github.com/paketo-buildpacks/packit/v2/postal" - "github.com/paketo-buildpacks/packit/v2/sbom" -) - -type SBOMGenerator struct { - GenerateFromDependencyCall struct { - mutex sync.Mutex - CallCount int - Receives struct { - Dependency postal.Dependency - Dir string - } - Returns struct { - SBOM sbom.SBOM - Error error - } - Stub func(postal.Dependency, string) (sbom.SBOM, error) - } -} - -func (f *SBOMGenerator) GenerateFromDependency(param1 postal.Dependency, param2 string) (sbom.SBOM, error) { - f.GenerateFromDependencyCall.mutex.Lock() - defer f.GenerateFromDependencyCall.mutex.Unlock() - f.GenerateFromDependencyCall.CallCount++ - f.GenerateFromDependencyCall.Receives.Dependency = param1 - f.GenerateFromDependencyCall.Receives.Dir = param2 - if f.GenerateFromDependencyCall.Stub != nil { - return f.GenerateFromDependencyCall.Stub(param1, param2) - } - return f.GenerateFromDependencyCall.Returns.SBOM, f.GenerateFromDependencyCall.Returns.Error -} diff --git a/pkg/installers/poetry/build_test.go b/pkg/installers/poetry/build_test.go index fcd8c16..c7fd824 100644 --- a/pkg/installers/poetry/build_test.go +++ b/pkg/installers/poetry/build_test.go @@ -22,6 +22,8 @@ import ( "github.com/sclevine/spec" pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + commonfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/fakes" + "github.com/paketo-buildpacks/python-installers/pkg/installers/poetry" "github.com/paketo-buildpacks/python-installers/pkg/installers/poetry/fakes" @@ -38,7 +40,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { dependencyManager *fakes.DependencyManager installProcess *fakes.InstallProcess siteProcess *fakes.SitePackageProcess - sbomGenerator *fakes.SBOMGenerator + sbomGenerator *commonfakes.SBOMGenerator buffer *bytes.Buffer @@ -80,7 +82,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { } // Syft SBOM - sbomGenerator = &fakes.SBOMGenerator{} + sbomGenerator = &commonfakes.SBOMGenerator{} sbomGenerator.GenerateFromDependencyCall.Returns.SBOM = sbom.SBOM{} installProcess = &fakes.InstallProcess{} diff --git a/pkg/installers/poetry/fakes/sbom_generator.go b/pkg/installers/poetry/fakes/sbom_generator.go deleted file mode 100644 index a0deccf..0000000 --- a/pkg/installers/poetry/fakes/sbom_generator.go +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2013-Present CloudFoundry.org Foundation, Inc. All Rights Reserved. -// -// SPDX-License-Identifier: Apache-2.0 - -package fakes - -import ( - "sync" - - "github.com/paketo-buildpacks/packit/v2/postal" - "github.com/paketo-buildpacks/packit/v2/sbom" -) - -type SBOMGenerator struct { - GenerateFromDependencyCall struct { - mutex sync.Mutex - CallCount int - Receives struct { - Dependency postal.Dependency - Dir string - } - Returns struct { - SBOM sbom.SBOM - Error error - } - Stub func(postal.Dependency, string) (sbom.SBOM, error) - } -} - -func (f *SBOMGenerator) GenerateFromDependency(param1 postal.Dependency, param2 string) (sbom.SBOM, error) { - f.GenerateFromDependencyCall.mutex.Lock() - defer f.GenerateFromDependencyCall.mutex.Unlock() - f.GenerateFromDependencyCall.CallCount++ - f.GenerateFromDependencyCall.Receives.Dependency = param1 - f.GenerateFromDependencyCall.Receives.Dir = param2 - if f.GenerateFromDependencyCall.Stub != nil { - return f.GenerateFromDependencyCall.Stub(param1, param2) - } - return f.GenerateFromDependencyCall.Returns.SBOM, f.GenerateFromDependencyCall.Returns.Error -} diff --git a/pkg/installers/uv/build.go b/pkg/installers/uv/build.go index 995b0d1..4471572 100644 --- a/pkg/installers/uv/build.go +++ b/pkg/installers/uv/build.go @@ -35,10 +35,6 @@ type InstallProcess interface { Execute(sourcePath, targetLayerPath, dependencyName string) error } -type SBOMGenerator interface { - GenerateFromDependency(dependency postal.Dependency, dir string) (sbom.SBOM, error) -} - // UvBuildParameters encapsulates the uv specific parameters for the // Build function type UvBuildParameters struct { diff --git a/pkg/installers/uv/build_test.go b/pkg/installers/uv/build_test.go index 1da2313..cf23e09 100644 --- a/pkg/installers/uv/build_test.go +++ b/pkg/installers/uv/build_test.go @@ -16,6 +16,8 @@ import ( "github.com/paketo-buildpacks/packit/v2/chronos" pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + commonfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/fakes" + "github.com/paketo-buildpacks/python-installers/pkg/installers/uv" "github.com/paketo-buildpacks/python-installers/pkg/installers/uv/fakes" @@ -40,7 +42,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { dependencyManager *fakes.DependencyManager installProcess *fakes.InstallProcess - sbomGenerator *fakes.SBOMGenerator + sbomGenerator *commonfakes.SBOMGenerator build packit.BuildFunc buildContext packit.BuildContext @@ -80,7 +82,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { } // Syft SBOM - sbomGenerator = &fakes.SBOMGenerator{} + sbomGenerator = &commonfakes.SBOMGenerator{} sbomGenerator.GenerateFromDependencyCall.Returns.SBOM = sbom.SBOM{} installProcess = &fakes.InstallProcess{} diff --git a/pkg/installers/uv/fakes/sbom_generator.go b/pkg/installers/uv/fakes/sbom_generator.go deleted file mode 100644 index a548333..0000000 --- a/pkg/installers/uv/fakes/sbom_generator.go +++ /dev/null @@ -1,41 +0,0 @@ -// SPDX-FileCopyrightText: © 2025 Idiap Research Institute -// SPDX-FileContributor: Samuel Gaist -// -// SPDX-License-Identifier: Apache-2.0 - -package fakes - -import ( - "sync" - - "github.com/paketo-buildpacks/packit/v2/postal" - "github.com/paketo-buildpacks/packit/v2/sbom" -) - -type SBOMGenerator struct { - GenerateFromDependencyCall struct { - mutex sync.Mutex - CallCount int - Receives struct { - Dependency postal.Dependency - Dir string - } - Returns struct { - SBOM sbom.SBOM - Error error - } - Stub func(postal.Dependency, string) (sbom.SBOM, error) - } -} - -func (f *SBOMGenerator) GenerateFromDependency(param1 postal.Dependency, param2 string) (sbom.SBOM, error) { - f.GenerateFromDependencyCall.mutex.Lock() - defer f.GenerateFromDependencyCall.mutex.Unlock() - f.GenerateFromDependencyCall.CallCount++ - f.GenerateFromDependencyCall.Receives.Dependency = param1 - f.GenerateFromDependencyCall.Receives.Dir = param2 - if f.GenerateFromDependencyCall.Stub != nil { - return f.GenerateFromDependencyCall.Stub(param1, param2) - } - return f.GenerateFromDependencyCall.Returns.SBOM, f.GenerateFromDependencyCall.Returns.Error -} From fefe7d3da990ab9b30c527b0858106dbfcbea167 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Fri, 20 Feb 2026 21:03:32 +0100 Subject: [PATCH 2/9] refactor: move sbom to own package --- build_test.go | 6 +++--- .../common/{ => sbom}/fakes/sbom_generator.go | 0 pkg/installers/common/sbom/sbom.go | 21 +++++++++++++++++++ pkg/installers/miniconda/build_test.go | 6 +++--- pkg/installers/pip/build_test.go | 6 +++--- pkg/installers/pipenv/build_test.go | 6 +++--- pkg/installers/pixi/build_test.go | 6 +++--- pkg/installers/poetry/build_test.go | 6 +++--- pkg/installers/uv/build_test.go | 6 +++--- 9 files changed, 42 insertions(+), 21 deletions(-) rename pkg/installers/common/{ => sbom}/fakes/sbom_generator.go (100%) create mode 100644 pkg/installers/common/sbom/sbom.go diff --git a/build_test.go b/build_test.go index 066449b..21907d0 100644 --- a/build_test.go +++ b/build_test.go @@ -23,7 +23,7 @@ import ( pythoninstallers "github.com/paketo-buildpacks/python-installers" pkgcommon "github.com/paketo-buildpacks/python-installers/pkg/installers/common" - commonfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/fakes" + sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" miniconda "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda" minicondafakes "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda/fakes" pip "github.com/paketo-buildpacks/python-installers/pkg/installers/pip" @@ -60,7 +60,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { buildContext packit.BuildContext // common - sbomGenerator *commonfakes.SBOMGenerator + sbomGenerator *sbomfakes.SBOMGenerator // dependencyManager *pipfakes.DependencyManager // conda @@ -103,7 +103,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { buffer = bytes.NewBuffer(nil) logger = scribe.NewEmitter(buffer) - sbomGenerator = &commonfakes.SBOMGenerator{} + sbomGenerator = &sbomfakes.SBOMGenerator{} sbomGenerator.GenerateFromDependencyCall.Returns.SBOM = sbom.SBOM{} // miniconda diff --git a/pkg/installers/common/fakes/sbom_generator.go b/pkg/installers/common/sbom/fakes/sbom_generator.go similarity index 100% rename from pkg/installers/common/fakes/sbom_generator.go rename to pkg/installers/common/sbom/fakes/sbom_generator.go diff --git a/pkg/installers/common/sbom/sbom.go b/pkg/installers/common/sbom/sbom.go new file mode 100644 index 0000000..2df24eb --- /dev/null +++ b/pkg/installers/common/sbom/sbom.go @@ -0,0 +1,21 @@ +// SPDX-FileCopyrightText: © 2025 Idiap Research Institute +// SPDX-FileContributor: Samuel Gaist +// +// SPDX-License-Identifier: Apache-2.0 + +package sbom + +import ( + "github.com/paketo-buildpacks/packit/v2/postal" + "github.com/paketo-buildpacks/packit/v2/sbom" +) + +type SBOMGenerator interface { + GenerateFromDependency(dependency postal.Dependency, path string) (sbom.SBOM, error) +} + +type Generator struct{} + +func (f Generator) GenerateFromDependency(dependency postal.Dependency, path string) (sbom.SBOM, error) { + return sbom.GenerateFromDependency(dependency, path) +} diff --git a/pkg/installers/miniconda/build_test.go b/pkg/installers/miniconda/build_test.go index 3a245c2..700a7d2 100644 --- a/pkg/installers/miniconda/build_test.go +++ b/pkg/installers/miniconda/build_test.go @@ -15,7 +15,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/chronos" pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" - commonfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/fakes" + sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda" "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda/fakes" @@ -41,7 +41,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { dependencyManager *fakes.DependencyManager runner *fakes.Runner - sbomGenerator *commonfakes.SBOMGenerator + sbomGenerator *sbomfakes.SBOMGenerator build packit.BuildFunc buildContext packit.BuildContext @@ -83,7 +83,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { runner = &fakes.Runner{} // Syft SBOM - sbomGenerator = &commonfakes.SBOMGenerator{} + sbomGenerator = &sbomfakes.SBOMGenerator{} sbomGenerator.GenerateFromDependencyCall.Returns.SBOM = sbom.SBOM{} buffer = bytes.NewBuffer(nil) diff --git a/pkg/installers/pip/build_test.go b/pkg/installers/pip/build_test.go index a819057..a1d2af5 100644 --- a/pkg/installers/pip/build_test.go +++ b/pkg/installers/pip/build_test.go @@ -23,7 +23,7 @@ import ( "github.com/sclevine/spec" pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" - commonfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/fakes" + sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/pip" "github.com/paketo-buildpacks/python-installers/pkg/installers/pip/fakes" @@ -41,7 +41,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { dependencyManager *fakes.DependencyManager installProcess *fakes.InstallProcess sitePackageProcess *fakes.SitePackageProcess - sbomGenerator *commonfakes.SBOMGenerator + sbomGenerator *sbomfakes.SBOMGenerator logger scribe.Emitter @@ -97,7 +97,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { sitePackageProcess.ExecuteCall.Returns.String = filepath.Join(layersDir, "pip", "lib", "python1.23", "site-packages") // Syft SBOM - sbomGenerator = &commonfakes.SBOMGenerator{} + sbomGenerator = &sbomfakes.SBOMGenerator{} sbomGenerator.GenerateFromDependencyCall.Returns.SBOM = sbom.SBOM{} buffer = bytes.NewBuffer(nil) diff --git a/pkg/installers/pipenv/build_test.go b/pkg/installers/pipenv/build_test.go index e4a7f81..e7d9f82 100644 --- a/pkg/installers/pipenv/build_test.go +++ b/pkg/installers/pipenv/build_test.go @@ -23,7 +23,7 @@ import ( "github.com/sclevine/spec" pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" - commonfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/fakes" + sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/pipenv" "github.com/paketo-buildpacks/python-installers/pkg/installers/pipenv/fakes" @@ -40,7 +40,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { dependencyManager *fakes.DependencyManager installProcess *fakes.InstallProcess siteProcess *fakes.SitePackageProcess - sbomGenerator *commonfakes.SBOMGenerator + sbomGenerator *sbomfakes.SBOMGenerator buffer *bytes.Buffer @@ -83,7 +83,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { siteProcess = &fakes.SitePackageProcess{} // Syft SBOM - sbomGenerator = &commonfakes.SBOMGenerator{} + sbomGenerator = &sbomfakes.SBOMGenerator{} sbomGenerator.GenerateFromDependencyCall.Returns.SBOM = sbom.SBOM{} buffer = bytes.NewBuffer(nil) diff --git a/pkg/installers/pixi/build_test.go b/pkg/installers/pixi/build_test.go index 0bd66dd..fecc1b7 100644 --- a/pkg/installers/pixi/build_test.go +++ b/pkg/installers/pixi/build_test.go @@ -16,7 +16,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/chronos" pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" - commonfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/fakes" + sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/pixi" "github.com/paketo-buildpacks/python-installers/pkg/installers/pixi/fakes" @@ -42,7 +42,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { dependencyManager *fakes.DependencyManager installProcess *fakes.InstallProcess - sbomGenerator *commonfakes.SBOMGenerator + sbomGenerator *sbomfakes.SBOMGenerator build packit.BuildFunc buildContext packit.BuildContext @@ -82,7 +82,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { } // Syft SBOM - sbomGenerator = &commonfakes.SBOMGenerator{} + sbomGenerator = &sbomfakes.SBOMGenerator{} sbomGenerator.GenerateFromDependencyCall.Returns.SBOM = sbom.SBOM{} installProcess = &fakes.InstallProcess{} diff --git a/pkg/installers/poetry/build_test.go b/pkg/installers/poetry/build_test.go index c7fd824..d719ccd 100644 --- a/pkg/installers/poetry/build_test.go +++ b/pkg/installers/poetry/build_test.go @@ -22,7 +22,7 @@ import ( "github.com/sclevine/spec" pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" - commonfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/fakes" + sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/poetry" "github.com/paketo-buildpacks/python-installers/pkg/installers/poetry/fakes" @@ -40,7 +40,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { dependencyManager *fakes.DependencyManager installProcess *fakes.InstallProcess siteProcess *fakes.SitePackageProcess - sbomGenerator *commonfakes.SBOMGenerator + sbomGenerator *sbomfakes.SBOMGenerator buffer *bytes.Buffer @@ -82,7 +82,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { } // Syft SBOM - sbomGenerator = &commonfakes.SBOMGenerator{} + sbomGenerator = &sbomfakes.SBOMGenerator{} sbomGenerator.GenerateFromDependencyCall.Returns.SBOM = sbom.SBOM{} installProcess = &fakes.InstallProcess{} diff --git a/pkg/installers/uv/build_test.go b/pkg/installers/uv/build_test.go index cf23e09..2151214 100644 --- a/pkg/installers/uv/build_test.go +++ b/pkg/installers/uv/build_test.go @@ -16,7 +16,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/chronos" pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" - commonfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/fakes" + sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/uv" "github.com/paketo-buildpacks/python-installers/pkg/installers/uv/fakes" @@ -42,7 +42,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { dependencyManager *fakes.DependencyManager installProcess *fakes.InstallProcess - sbomGenerator *commonfakes.SBOMGenerator + sbomGenerator *sbomfakes.SBOMGenerator build packit.BuildFunc buildContext packit.BuildContext @@ -82,7 +82,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { } // Syft SBOM - sbomGenerator = &commonfakes.SBOMGenerator{} + sbomGenerator = &sbomfakes.SBOMGenerator{} sbomGenerator.GenerateFromDependencyCall.Returns.SBOM = sbom.SBOM{} installProcess = &fakes.InstallProcess{} From 7ed62dd05664dffa216313b3e6c04caf2af0d3e7 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Fri, 20 Feb 2026 21:58:09 +0100 Subject: [PATCH 3/9] refactor: move build related types in own module And removed common.go file --- build.go | 4 +-- build_test.go | 20 ++++++------- detect_test.go | 16 +++++----- .../common/{common.go => build/build.go} | 18 +++-------- pkg/installers/miniconda/build.go | 4 +-- pkg/installers/miniconda/build_test.go | 26 ++++++++-------- pkg/installers/miniconda/detect.go | 4 +-- pkg/installers/miniconda/detect_test.go | 4 +-- pkg/installers/pip/build.go | 4 +-- pkg/installers/pip/build_test.go | 30 +++++++++---------- pkg/installers/pip/detect.go | 8 ++--- pkg/installers/pip/detect_test.go | 20 ++++++------- pkg/installers/pipenv/build.go | 4 +-- pkg/installers/pipenv/build_test.go | 30 +++++++++---------- pkg/installers/pipenv/detect.go | 6 ++-- pkg/installers/pipenv/detect_test.go | 12 ++++---- pkg/installers/pixi/build.go | 4 +-- pkg/installers/pixi/build_test.go | 26 ++++++++-------- pkg/installers/pixi/detect.go | 4 +-- pkg/installers/pixi/detect_test.go | 4 +-- pkg/installers/poetry/build.go | 4 +-- pkg/installers/poetry/build_test.go | 24 +++++++-------- pkg/installers/poetry/detect.go | 6 ++-- pkg/installers/poetry/detect_test.go | 12 ++++---- pkg/installers/uv/build.go | 4 +-- pkg/installers/uv/build_test.go | 26 ++++++++-------- pkg/installers/uv/detect.go | 4 +-- pkg/installers/uv/detect_test.go | 4 +-- run/main.go | 7 +++-- 29 files changed, 165 insertions(+), 174 deletions(-) rename pkg/installers/common/{common.go => build/build.go} (69%) diff --git a/build.go b/build.go index b84bf8b..c9c7092 100644 --- a/build.go +++ b/build.go @@ -18,7 +18,7 @@ import ( poetry "github.com/paketo-buildpacks/python-installers/pkg/installers/poetry" uv "github.com/paketo-buildpacks/python-installers/pkg/installers/uv" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" ) type PackagerParameters interface { @@ -26,7 +26,7 @@ type PackagerParameters interface { func Build( logger scribe.Emitter, - commonBuildParameters pythoninstallers.CommonBuildParameters, + commonBuildParameters build.CommonBuildParameters, buildParameters map[string]PackagerParameters, ) packit.BuildFunc { return func(context packit.BuildContext) (packit.BuildResult, error) { diff --git a/build_test.go b/build_test.go index 21907d0..9246971 100644 --- a/build_test.go +++ b/build_test.go @@ -22,7 +22,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/scribe" pythoninstallers "github.com/paketo-buildpacks/python-installers" - pkgcommon "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" miniconda "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda" minicondafakes "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda/fakes" @@ -56,7 +56,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { buffer *bytes.Buffer logger scribe.Emitter - build packit.BuildFunc + buildFunc packit.BuildFunc buildContext packit.BuildContext // common @@ -90,7 +90,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { pixiDependencyManager *pixifakes.DependencyManager pixiInstallProcess *pixifakes.InstallProcess - buildParameters pkgcommon.CommonBuildParameters + buildParameters build.CommonBuildParameters testPlans []TestPlan ) @@ -286,8 +286,8 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { pixiInstallProcess = &pixifakes.InstallProcess{} - buildParameters = pkgcommon.CommonBuildParameters{ - SbomGenerator: pkgcommon.Generator{}, + buildParameters = build.CommonBuildParameters{ + SbomGenerator: sbomGenerator, Clock: chronos.DefaultClock, Logger: logger, } @@ -322,7 +322,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }, } - build = pythoninstallers.Build(logger, buildParameters, packagerParameters) + buildFunc = pythoninstallers.Build(logger, buildParameters, packagerParameters) buildContext = packit.BuildContext{ BuildpackInfo: packit.BuildpackInfo{ @@ -436,7 +436,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { for _, testPlan := range testPlans { logger.Detail("Doing: %s", testPlan) buildContext.Plan = testPlan.Plan - result, err := build(buildContext) + result, err := buildFunc(buildContext) Expect(err).NotTo(HaveOccurred()) layers := result.Layers @@ -470,7 +470,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { for _, testPlan := range orderTestPlans { logger.Detail("Doing: %s", testPlan) buildContext.Plan = testPlan - result, err := build(buildContext) + result, err := buildFunc(buildContext) Expect(err).NotTo(HaveOccurred()) layers := result.Layers @@ -483,11 +483,11 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { it("fails if packager parameters is missing", func() { packagerParameters := map[string]pythoninstallers.PackagerParameters{} - build = pythoninstallers.Build(logger, buildParameters, packagerParameters) + buildFunc = pythoninstallers.Build(logger, buildParameters, packagerParameters) for _, testPlan := range testPlans { buildContext.Plan = testPlan.Plan - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(HaveOccurred()) } }) diff --git a/detect_test.go b/detect_test.go index abc6e69..c247273 100644 --- a/detect_test.go +++ b/detect_test.go @@ -15,7 +15,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/scribe" pythoninstallers "github.com/paketo-buildpacks/python-installers" - common "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" miniconda "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda" pip "github.com/paketo-buildpacks/python-installers/pkg/installers/pip" @@ -65,7 +65,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { Requires: []packit.BuildPlanRequirement{ { Name: pip.CPython, - Metadata: common.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Build: true, }, }, @@ -88,14 +88,14 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { Requires: []packit.BuildPlanRequirement{ { Name: pipenv.CPython, - Metadata: common.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Build: true, Launch: false, }, }, { Name: pipenv.Pip, - Metadata: common.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Build: true, Launch: false, }, @@ -141,7 +141,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { Requires: []packit.BuildPlanRequirement{ { Name: poetry.CPython, - Metadata: common.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Build: true, Version: "1.2.3", VersionSource: "pyproject.toml", @@ -149,7 +149,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { }, { Name: poetry.Pip, - Metadata: common.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Build: true, }, }, @@ -187,7 +187,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { Requires: []packit.BuildPlanRequirement{ { Name: poetry.CPython, - Metadata: common.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Build: true, Version: "1.2.3", VersionSource: "pyproject.toml", @@ -195,7 +195,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { }, { Name: poetry.Pip, - Metadata: common.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Build: true, }, }, diff --git a/pkg/installers/common/common.go b/pkg/installers/common/build/build.go similarity index 69% rename from pkg/installers/common/common.go rename to pkg/installers/common/build/build.go index 1baeab4..7c6a1ca 100644 --- a/pkg/installers/common/common.go +++ b/pkg/installers/common/build/build.go @@ -3,29 +3,19 @@ // // SPDX-License-Identifier: Apache-2.0 -package pythoninstallers +package build import ( "github.com/paketo-buildpacks/packit/v2/chronos" - "github.com/paketo-buildpacks/packit/v2/postal" - "github.com/paketo-buildpacks/packit/v2/sbom" "github.com/paketo-buildpacks/packit/v2/scribe" -) - -type SBOMGenerator interface { - GenerateFromDependency(dependency postal.Dependency, path string) (sbom.SBOM, error) -} -type Generator struct{} - -func (f Generator) GenerateFromDependency(dependency postal.Dependency, path string) (sbom.SBOM, error) { - return sbom.GenerateFromDependency(dependency, path) -} + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom" +) // CommonBuildParameters are the parameters shared // by all packager build function implementation type CommonBuildParameters struct { - SbomGenerator SBOMGenerator + SbomGenerator sbom.SBOMGenerator Clock chronos.Clock Logger scribe.Emitter } diff --git a/pkg/installers/miniconda/build.go b/pkg/installers/miniconda/build.go index e2326d0..8c3d861 100644 --- a/pkg/installers/miniconda/build.go +++ b/pkg/installers/miniconda/build.go @@ -15,7 +15,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/postal" "github.com/paketo-buildpacks/packit/v2/sbom" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" ) //go:generate faux --interface DependencyManager --output fakes/dependency_manager.go @@ -59,7 +59,7 @@ type CondaBuildParameters struct { // the dependency to reuse the layer when possible. func Build( buildParameters CondaBuildParameters, - parameters pythoninstallers.CommonBuildParameters, + parameters build.CommonBuildParameters, ) packit.BuildFunc { return func(context packit.BuildContext) (packit.BuildResult, error) { runner := buildParameters.Runner diff --git a/pkg/installers/miniconda/build_test.go b/pkg/installers/miniconda/build_test.go index 700a7d2..39ebf9e 100644 --- a/pkg/installers/miniconda/build_test.go +++ b/pkg/installers/miniconda/build_test.go @@ -14,7 +14,7 @@ import ( "github.com/paketo-buildpacks/packit/v2" "github.com/paketo-buildpacks/packit/v2/chronos" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda" @@ -43,7 +43,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { runner *fakes.Runner sbomGenerator *sbomfakes.SBOMGenerator - build packit.BuildFunc + buildFunc packit.BuildFunc buildContext packit.BuildContext ) @@ -89,12 +89,12 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { buffer = bytes.NewBuffer(nil) logger := scribe.NewEmitter(buffer) - build = miniconda.Build( + buildFunc = miniconda.Build( miniconda.CondaBuildParameters{ DependencyManager: dependencyManager, Runner: runner, }, - pythoninstallers.CommonBuildParameters{ + build.CommonBuildParameters{ SbomGenerator: sbomGenerator, Clock: chronos.DefaultClock, Logger: logger, @@ -124,7 +124,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns a result that installs conda", func() { - result, err := build(buildContext) + result, err := buildFunc(buildContext) Expect(err).NotTo(HaveOccurred()) Expect(result.Layers).To(HaveLen(1)) @@ -202,7 +202,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns a layer with build and launch set true and the BOM is set for build and launch", func() { - result, err := build(buildContext) + result, err := buildFunc(buildContext) Expect(err).NotTo(HaveOccurred()) Expect(result.Layers).To(HaveLen(1)) @@ -255,7 +255,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError("resolve call failed")) }) @@ -271,7 +271,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("permission denied"))) }) @@ -288,7 +288,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("permission denied"))) }) @@ -300,7 +300,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError("deliver call failed")) }) @@ -312,7 +312,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError("run call failed")) }) @@ -324,7 +324,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(`unsupported SBOM format: 'random-format'`)) }) @@ -336,7 +336,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("failed to generate SBOM"))) }) diff --git a/pkg/installers/miniconda/detect.go b/pkg/installers/miniconda/detect.go index 7f9d199..17b33ae 100644 --- a/pkg/installers/miniconda/detect.go +++ b/pkg/installers/miniconda/detect.go @@ -9,7 +9,7 @@ import ( "github.com/paketo-buildpacks/packit/v2" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" ) // Detect will return a packit.DetectFunc that will be invoked during the @@ -24,7 +24,7 @@ func Detect() packit.DetectFunc { requirements = []packit.BuildPlanRequirement{ { Name: Conda, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ VersionSource: "BP_MINICONDA_VERSION", Version: version, }, diff --git a/pkg/installers/miniconda/detect_test.go b/pkg/installers/miniconda/detect_test.go index 6ae9e06..334d34a 100644 --- a/pkg/installers/miniconda/detect_test.go +++ b/pkg/installers/miniconda/detect_test.go @@ -10,7 +10,7 @@ import ( "github.com/paketo-buildpacks/packit/v2" "github.com/sclevine/spec" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda" @@ -62,7 +62,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { Requires: []packit.BuildPlanRequirement{ { Name: "conda", - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Version: "some-version", VersionSource: "BP_MINICONDA_VERSION", }, diff --git a/pkg/installers/pip/build.go b/pkg/installers/pip/build.go index 425a1c4..5980c90 100644 --- a/pkg/installers/pip/build.go +++ b/pkg/installers/pip/build.go @@ -16,7 +16,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/postal" "github.com/paketo-buildpacks/packit/v2/sbom" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" ) //go:generate faux --interface DependencyManager --output fakes/dependency_manager.go @@ -58,7 +58,7 @@ type PipBuildParameters struct { // the dependency to reuse the layer when possible. func Build( buildParameters PipBuildParameters, - parameters pythoninstallers.CommonBuildParameters, + parameters build.CommonBuildParameters, ) packit.BuildFunc { return func(context packit.BuildContext) (packit.BuildResult, error) { installProcess := buildParameters.InstallProcess diff --git a/pkg/installers/pip/build_test.go b/pkg/installers/pip/build_test.go index a1d2af5..6b7ef41 100644 --- a/pkg/installers/pip/build_test.go +++ b/pkg/installers/pip/build_test.go @@ -22,7 +22,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/scribe" "github.com/sclevine/spec" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/pip" @@ -47,7 +47,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { buffer *bytes.Buffer - build packit.BuildFunc + buildFunc packit.BuildFunc buildContext packit.BuildContext ) @@ -103,13 +103,13 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { buffer = bytes.NewBuffer(nil) logger = scribe.NewEmitter(buffer) - build = pip.Build( + buildFunc = pip.Build( pip.PipBuildParameters{ dependencyManager, installProcess, sitePackageProcess, }, - pythoninstallers.CommonBuildParameters{ + build.CommonBuildParameters{ SbomGenerator: sbomGenerator, Clock: chronos.DefaultClock, Logger: logger, @@ -142,7 +142,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns a result that installs pip", func() { - result, err := build(buildContext) + result, err := buildFunc(buildContext) Expect(err).NotTo(HaveOccurred()) Expect(result.Layers).To(HaveLen(2)) @@ -227,7 +227,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("makes the layer available at the right times", func() { - result, err := build(buildContext) + result, err := buildFunc(buildContext) Expect(err).NotTo(HaveOccurred()) Expect(result.Layers).To(HaveLen(2)) @@ -295,7 +295,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("skips the build process if the cached dependency sha matches the selected dependency sha", func() { - result, err := build(buildContext) + result, err := buildFunc(buildContext) Expect(err).NotTo(HaveOccurred()) Expect(result.Layers).To(HaveLen(2)) @@ -329,7 +329,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { dependencyManager.ResolveCall.Returns.Error = errors.New("failed to resolve dependency") }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("failed to resolve dependency"))) }) @@ -345,7 +345,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("permission denied"))) }) @@ -362,7 +362,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("permission denied"))) }) @@ -373,7 +373,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { dependencyManager.DeliverCall.Returns.Error = errors.New("failed to install dependency") }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("failed to install dependency"))) }) @@ -385,7 +385,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("failed to find site-packages dir"))) }) }) @@ -396,7 +396,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("pip installation failed: site packages are missing from the pip layer"))) }) }) @@ -407,7 +407,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(`unsupported SBOM format: 'random-format'`)) }) }) @@ -418,7 +418,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("failed to generate SBOM"))) }) }) diff --git a/pkg/installers/pip/detect.go b/pkg/installers/pip/detect.go index 2794337..a636737 100644 --- a/pkg/installers/pip/detect.go +++ b/pkg/installers/pip/detect.go @@ -10,7 +10,7 @@ import ( "github.com/paketo-buildpacks/packit/v2" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" ) // Return a pip requirement @@ -32,7 +32,7 @@ func GetVersionedRequirement() *packit.BuildPlanRequirement { return &packit.BuildPlanRequirement{ Name: Pip, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ VersionSource: "BP_PIP_VERSION", Version: pipVersion, }, @@ -47,7 +47,7 @@ func GetRequirement() packit.BuildPlanRequirement { return packit.BuildPlanRequirement{ Name: Pip, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Build: true, }, } @@ -67,7 +67,7 @@ func Detect() packit.DetectFunc { requirements := []packit.BuildPlanRequirement{ { Name: CPython, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Build: true, }, }, diff --git a/pkg/installers/pip/detect_test.go b/pkg/installers/pip/detect_test.go index 9f073ae..2183d46 100644 --- a/pkg/installers/pip/detect_test.go +++ b/pkg/installers/pip/detect_test.go @@ -12,7 +12,7 @@ import ( . "github.com/onsi/gomega" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" "github.com/paketo-buildpacks/python-installers/pkg/installers/pip" ) @@ -41,7 +41,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { Requires: []packit.BuildPlanRequirement{ { Name: pip.CPython, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Build: true, }, }, @@ -65,13 +65,13 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { Requires: []packit.BuildPlanRequirement{ { Name: pip.CPython, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Build: true, }, }, { Name: pip.Pip, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Version: "some-version", VersionSource: "BP_PIP_VERSION", }, @@ -97,13 +97,13 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { Requires: []packit.BuildPlanRequirement{ { Name: pip.CPython, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Build: true, }, }, { Name: pip.Pip, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Version: "2.11.0", VersionSource: "BP_PIP_VERSION", }, @@ -130,13 +130,13 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { Requires: []packit.BuildPlanRequirement{ { Name: pip.CPython, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Build: true, }, }, { Name: pip.Pip, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Version: "22.1.3", VersionSource: "BP_PIP_VERSION", }, @@ -163,13 +163,13 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { Requires: []packit.BuildPlanRequirement{ { Name: pip.CPython, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Build: true, }, }, { Name: pip.Pip, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Version: "some.other", VersionSource: "BP_PIP_VERSION", }, diff --git a/pkg/installers/pipenv/build.go b/pkg/installers/pipenv/build.go index 67ee8f7..17a6387 100644 --- a/pkg/installers/pipenv/build.go +++ b/pkg/installers/pipenv/build.go @@ -15,7 +15,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/postal" "github.com/paketo-buildpacks/packit/v2/sbom" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" ) //go:generate faux --interface DependencyManager --output fakes/dependency_manager.go @@ -56,7 +56,7 @@ type PipEnvBuildParameters struct { // the dependency to reuse the layer when possible. func Build( buildParameters PipEnvBuildParameters, - parameters pythoninstallers.CommonBuildParameters, + parameters build.CommonBuildParameters, ) packit.BuildFunc { return func(context packit.BuildContext) (packit.BuildResult, error) { installProcess := buildParameters.InstallProcess diff --git a/pkg/installers/pipenv/build_test.go b/pkg/installers/pipenv/build_test.go index e7d9f82..668086a 100644 --- a/pkg/installers/pipenv/build_test.go +++ b/pkg/installers/pipenv/build_test.go @@ -22,7 +22,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/scribe" "github.com/sclevine/spec" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/pipenv" "github.com/paketo-buildpacks/python-installers/pkg/installers/pipenv/fakes" @@ -46,7 +46,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { logger scribe.Emitter - build packit.BuildFunc + buildFunc packit.BuildFunc buildContext packit.BuildContext ) @@ -91,13 +91,13 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { siteProcess.ExecuteCall.Returns.String = filepath.Join(layersDir, "pipenv", "lib", "python3.8", "site-packages") - build = pipenv.Build( + buildFunc = pipenv.Build( pipenv.PipEnvBuildParameters{ dependencyManager, installProcess, siteProcess, }, - pythoninstallers.CommonBuildParameters{ + build.CommonBuildParameters{ SbomGenerator: sbomGenerator, Clock: chronos.DefaultClock, Logger: logger, @@ -125,7 +125,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns a result that installs pipenv", func() { - result, err := build(buildContext) + result, err := buildFunc(buildContext) Expect(err).NotTo(HaveOccurred()) Expect(result.Layers).To(HaveLen(1)) @@ -188,7 +188,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("makes the layer available at the right times", func() { - result, err := build(buildContext) + result, err := buildFunc(buildContext) Expect(err).NotTo(HaveOccurred()) Expect(result.Layers).To(HaveLen(1)) @@ -249,7 +249,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("skips the build process if the cached dependency sha matches the selected dependency sha", func() { - result, err := build(buildContext) + result, err := buildFunc(buildContext) Expect(err).NotTo(HaveOccurred()) Expect(result.Layers).To(HaveLen(1)) @@ -273,7 +273,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { dependencyManager.ResolveCall.Returns.Error = errors.New("failed to resolve dependency") }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("failed to resolve dependency"))) }) @@ -289,7 +289,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("permission denied"))) }) @@ -306,7 +306,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("permission denied"))) }) @@ -317,7 +317,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { installProcess.ExecuteCall.Returns.Error = errors.New("failed to install dependency") }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("failed to install dependency"))) }) @@ -329,7 +329,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("failed to find site-packages dir"))) }) }) @@ -340,7 +340,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("pipenv installation failed: site packages are missing from the pipenv layer"))) }) }) @@ -351,7 +351,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(`unsupported SBOM format: 'random-format'`)) }) }) @@ -362,7 +362,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("failed to generate SBOM"))) }) }) diff --git a/pkg/installers/pipenv/detect.go b/pkg/installers/pipenv/detect.go index 1923cb3..be132c9 100644 --- a/pkg/installers/pipenv/detect.go +++ b/pkg/installers/pipenv/detect.go @@ -9,7 +9,7 @@ import ( "github.com/paketo-buildpacks/packit/v2" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" "github.com/paketo-buildpacks/python-installers/pkg/installers/pip" ) @@ -27,7 +27,7 @@ func Detect() packit.DetectFunc { requirements := []packit.BuildPlanRequirement{ { Name: CPython, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Build: true, }, }, @@ -39,7 +39,7 @@ func Detect() packit.DetectFunc { if ok { requirements = append(requirements, packit.BuildPlanRequirement{ Name: Pipenv, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Version: pipEnvVersion, VersionSource: "BP_PIPENV_VERSION", }, diff --git a/pkg/installers/pipenv/detect_test.go b/pkg/installers/pipenv/detect_test.go index 6a19823..0dfc2cc 100644 --- a/pkg/installers/pipenv/detect_test.go +++ b/pkg/installers/pipenv/detect_test.go @@ -13,7 +13,7 @@ import ( "github.com/sclevine/spec" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" "github.com/paketo-buildpacks/python-installers/pkg/installers/pipenv" . "github.com/onsi/gomega" @@ -50,14 +50,14 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { Requires: []packit.BuildPlanRequirement{ { Name: pipenv.CPython, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Build: true, Launch: false, }, }, { Name: pipenv.Pip, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Build: true, Launch: false, }, @@ -86,21 +86,21 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { Requires: []packit.BuildPlanRequirement{ { Name: pipenv.CPython, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Build: true, Launch: false, }, }, { Name: pipenv.Pip, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Build: true, Launch: false, }, }, { Name: pipenv.Pipenv, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Version: "1.2.3", VersionSource: "BP_PIPENV_VERSION", }, diff --git a/pkg/installers/pixi/build.go b/pkg/installers/pixi/build.go index ef38b2f..52f7faf 100644 --- a/pkg/installers/pixi/build.go +++ b/pkg/installers/pixi/build.go @@ -15,7 +15,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/postal" "github.com/paketo-buildpacks/packit/v2/sbom" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" ) //go:generate faux --interface DependencyManager --output fakes/dependency_manager.go @@ -51,7 +51,7 @@ type PixiBuildParameters struct { // the dependency to reuse the layer when possible. func Build( buildParameters PixiBuildParameters, - parameters pythoninstallers.CommonBuildParameters, + parameters build.CommonBuildParameters, ) packit.BuildFunc { return func(context packit.BuildContext) (packit.BuildResult, error) { dependencyManager := buildParameters.DependencyManager diff --git a/pkg/installers/pixi/build_test.go b/pkg/installers/pixi/build_test.go index fecc1b7..2e9504d 100644 --- a/pkg/installers/pixi/build_test.go +++ b/pkg/installers/pixi/build_test.go @@ -15,7 +15,7 @@ import ( "github.com/paketo-buildpacks/packit/v2" "github.com/paketo-buildpacks/packit/v2/chronos" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/pixi" @@ -44,7 +44,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { installProcess *fakes.InstallProcess sbomGenerator *sbomfakes.SBOMGenerator - build packit.BuildFunc + buildFunc packit.BuildFunc buildContext packit.BuildContext ) @@ -90,12 +90,12 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { buffer = bytes.NewBuffer(nil) logger := scribe.NewEmitter(buffer) - build = pixi.Build( + buildFunc = pixi.Build( pixi.PixiBuildParameters{ DependencyManager: dependencyManager, InstallProcess: installProcess, }, - pythoninstallers.CommonBuildParameters{ + build.CommonBuildParameters{ SbomGenerator: sbomGenerator, Clock: chronos.DefaultClock, Logger: logger, @@ -125,7 +125,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns a result that installs pixi", func() { - result, err := build(buildContext) + result, err := buildFunc(buildContext) Expect(err).NotTo(HaveOccurred()) Expect(result.Layers).To(HaveLen(1)) @@ -197,7 +197,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns a layer with build and launch set true and the BOM is set for build and launch", func() { - result, err := build(buildContext) + result, err := buildFunc(buildContext) Expect(err).NotTo(HaveOccurred()) Expect(result.Layers).To(HaveLen(1)) @@ -250,7 +250,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError("resolve call failed")) }) @@ -266,7 +266,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("permission denied"))) }) @@ -283,7 +283,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("permission denied"))) }) @@ -295,7 +295,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError("deliver call failed")) }) @@ -307,7 +307,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(`unsupported SBOM format: 'random-format'`)) }) @@ -319,7 +319,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("failed to generate SBOM"))) }) @@ -331,7 +331,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("failed to copy files"))) }) diff --git a/pkg/installers/pixi/detect.go b/pkg/installers/pixi/detect.go index 5428286..9c55d14 100644 --- a/pkg/installers/pixi/detect.go +++ b/pkg/installers/pixi/detect.go @@ -12,7 +12,7 @@ import ( "github.com/paketo-buildpacks/packit/v2" "github.com/paketo-buildpacks/packit/v2/fs" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" ) // Detect will return a packit.DetectFunc that will be invoked during the @@ -47,7 +47,7 @@ func Detect() packit.DetectFunc { plan.Requires = []packit.BuildPlanRequirement{ { Name: Pixi, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ VersionSource: "BP_PIXI_VERSION", Version: version, }, diff --git a/pkg/installers/pixi/detect_test.go b/pkg/installers/pixi/detect_test.go index b4abd4a..40ea962 100644 --- a/pkg/installers/pixi/detect_test.go +++ b/pkg/installers/pixi/detect_test.go @@ -13,7 +13,7 @@ import ( "github.com/paketo-buildpacks/packit/v2" "github.com/sclevine/spec" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" "github.com/paketo-buildpacks/python-installers/pkg/installers/pixi" . "github.com/onsi/gomega" @@ -77,7 +77,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { Requires: []packit.BuildPlanRequirement{ { Name: pixi.Pixi, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ VersionSource: "BP_PIXI_VERSION", Version: "some-version", }, diff --git a/pkg/installers/poetry/build.go b/pkg/installers/poetry/build.go index baea877..1bcbda2 100644 --- a/pkg/installers/poetry/build.go +++ b/pkg/installers/poetry/build.go @@ -15,7 +15,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/postal" "github.com/paketo-buildpacks/packit/v2/sbom" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" ) //go:generate faux --interface DependencyManager --output fakes/dependency_manager.go @@ -52,7 +52,7 @@ type PoetryBuildParameters struct { func Build( buildParameters PoetryBuildParameters, - parameters pythoninstallers.CommonBuildParameters, + parameters build.CommonBuildParameters, ) packit.BuildFunc { return func(context packit.BuildContext) (packit.BuildResult, error) { installProcess := buildParameters.InstallProcess diff --git a/pkg/installers/poetry/build_test.go b/pkg/installers/poetry/build_test.go index d719ccd..f12d1f0 100644 --- a/pkg/installers/poetry/build_test.go +++ b/pkg/installers/poetry/build_test.go @@ -21,7 +21,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/scribe" "github.com/sclevine/spec" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/poetry" @@ -44,7 +44,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { buffer *bytes.Buffer - build packit.BuildFunc + buildFunc packit.BuildFunc buildContext packit.BuildContext ) @@ -92,13 +92,13 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { buffer = bytes.NewBuffer(nil) logger := scribe.NewEmitter(buffer) - build = poetry.Build( + buildFunc = poetry.Build( poetry.PoetryBuildParameters{ dependencyManager, installProcess, siteProcess, }, - pythoninstallers.CommonBuildParameters{ + build.CommonBuildParameters{ SbomGenerator: sbomGenerator, Clock: chronos.DefaultClock, Logger: logger, @@ -129,7 +129,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns a result that installs poetry", func() { - result, err := build(buildContext) + result, err := buildFunc(buildContext) Expect(err).NotTo(HaveOccurred()) Expect(result.Layers).To(HaveLen(1)) @@ -199,7 +199,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("makes the layer available in those phases", func() { - result, err := build(buildContext) + result, err := buildFunc(buildContext) Expect(err).NotTo(HaveOccurred()) Expect(result.Layers).To(HaveLen(1)) @@ -252,7 +252,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError("failed to resolve dependency")) }) }) @@ -264,7 +264,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("failed to parse layer content metadata"))) }) }) @@ -280,7 +280,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("could not remove file"))) }) }) @@ -291,7 +291,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError("failed to run install process")) }) }) @@ -302,7 +302,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(`unsupported SBOM format: 'random-format'`)) }) }) @@ -313,7 +313,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("failed to generate SBOM"))) }) }) diff --git a/pkg/installers/poetry/detect.go b/pkg/installers/poetry/detect.go index 76d73cc..5f7d480 100644 --- a/pkg/installers/poetry/detect.go +++ b/pkg/installers/poetry/detect.go @@ -8,7 +8,7 @@ import ( "os" "path/filepath" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" "github.com/paketo-buildpacks/python-installers/pkg/installers/pip" "github.com/paketo-buildpacks/packit/v2" @@ -58,7 +58,7 @@ func Detect(parser PyProjectParser) packit.DetectFunc { requirements := []packit.BuildPlanRequirement{ { Name: CPython, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Build: true, Version: pythonVersion, VersionSource: PyProjectTomlFile, @@ -71,7 +71,7 @@ func Detect(parser PyProjectParser) packit.DetectFunc { if version, ok := os.LookupEnv("BP_POETRY_VERSION"); ok { requirements = append(requirements, packit.BuildPlanRequirement{ Name: PoetryDependency, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ VersionSource: "BP_POETRY_VERSION", Version: version, }, diff --git a/pkg/installers/poetry/detect_test.go b/pkg/installers/poetry/detect_test.go index b139434..a8a5446 100644 --- a/pkg/installers/poetry/detect_test.go +++ b/pkg/installers/poetry/detect_test.go @@ -17,7 +17,7 @@ import ( "github.com/paketo-buildpacks/python-installers/pkg/installers/poetry" "github.com/paketo-buildpacks/python-installers/pkg/installers/poetry/fakes" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" ) func testDetect(t *testing.T, context spec.G, it spec.S) { @@ -64,7 +64,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { Requires: []packit.BuildPlanRequirement{ { Name: poetry.CPython, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Build: true, Version: "1.2.3", VersionSource: "pyproject.toml", @@ -72,7 +72,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { }, { Name: poetry.Pip, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Build: true, }, }, @@ -101,7 +101,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { Requires: []packit.BuildPlanRequirement{ { Name: poetry.CPython, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Build: true, Version: "1.2.3", VersionSource: "pyproject.toml", @@ -109,13 +109,13 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { }, { Name: poetry.Pip, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ Build: true, }, }, { Name: poetry.PoetryDependency, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ VersionSource: "BP_POETRY_VERSION", Version: "some-version", }, diff --git a/pkg/installers/uv/build.go b/pkg/installers/uv/build.go index 4471572..827ffd8 100644 --- a/pkg/installers/uv/build.go +++ b/pkg/installers/uv/build.go @@ -15,7 +15,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/postal" "github.com/paketo-buildpacks/packit/v2/sbom" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" ) //go:generate faux --interface DependencyManager --output fakes/dependency_manager.go @@ -51,7 +51,7 @@ type UvBuildParameters struct { // the dependency to reuse the layer when possible. func Build( buildParameters UvBuildParameters, - parameters pythoninstallers.CommonBuildParameters, + parameters build.CommonBuildParameters, ) packit.BuildFunc { return func(context packit.BuildContext) (packit.BuildResult, error) { dependencyManager := buildParameters.DependencyManager diff --git a/pkg/installers/uv/build_test.go b/pkg/installers/uv/build_test.go index 2151214..60e8e13 100644 --- a/pkg/installers/uv/build_test.go +++ b/pkg/installers/uv/build_test.go @@ -15,7 +15,7 @@ import ( "github.com/paketo-buildpacks/packit/v2" "github.com/paketo-buildpacks/packit/v2/chronos" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/uv" @@ -44,7 +44,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { installProcess *fakes.InstallProcess sbomGenerator *sbomfakes.SBOMGenerator - build packit.BuildFunc + buildFunc packit.BuildFunc buildContext packit.BuildContext ) @@ -90,12 +90,12 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { buffer = bytes.NewBuffer(nil) logger := scribe.NewEmitter(buffer) - build = uv.Build( + buildFunc = uv.Build( uv.UvBuildParameters{ DependencyManager: dependencyManager, InstallProcess: installProcess, }, - pythoninstallers.CommonBuildParameters{ + build.CommonBuildParameters{ SbomGenerator: sbomGenerator, Clock: chronos.DefaultClock, Logger: logger, @@ -125,7 +125,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns a result that installs uv", func() { - result, err := build(buildContext) + result, err := buildFunc(buildContext) Expect(err).NotTo(HaveOccurred()) Expect(result.Layers).To(HaveLen(1)) @@ -197,7 +197,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns a layer with build and launch set true and the BOM is set for build and launch", func() { - result, err := build(buildContext) + result, err := buildFunc(buildContext) Expect(err).NotTo(HaveOccurred()) Expect(result.Layers).To(HaveLen(1)) @@ -250,7 +250,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError("resolve call failed")) }) @@ -266,7 +266,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("permission denied"))) }) @@ -283,7 +283,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("permission denied"))) }) @@ -295,7 +295,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError("deliver call failed")) }) @@ -307,7 +307,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(`unsupported SBOM format: 'random-format'`)) }) @@ -319,7 +319,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("failed to generate SBOM"))) }) @@ -331,7 +331,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { }) it("returns an error", func() { - _, err := build(buildContext) + _, err := buildFunc(buildContext) Expect(err).To(MatchError(ContainSubstring("failed to copy files"))) }) diff --git a/pkg/installers/uv/detect.go b/pkg/installers/uv/detect.go index b571b39..c2efbc3 100644 --- a/pkg/installers/uv/detect.go +++ b/pkg/installers/uv/detect.go @@ -12,7 +12,7 @@ import ( "github.com/paketo-buildpacks/packit/v2" "github.com/paketo-buildpacks/packit/v2/fs" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" ) // Detect will return a packit.DetectFunc that will be invoked during the @@ -49,7 +49,7 @@ func Detect() packit.DetectFunc { plan.Requires = []packit.BuildPlanRequirement{ { Name: Uv, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ VersionSource: "BP_UV_VERSION", Version: version, }, diff --git a/pkg/installers/uv/detect_test.go b/pkg/installers/uv/detect_test.go index c2ea8aa..69e3c50 100644 --- a/pkg/installers/uv/detect_test.go +++ b/pkg/installers/uv/detect_test.go @@ -13,7 +13,7 @@ import ( "github.com/paketo-buildpacks/packit/v2" "github.com/sclevine/spec" - pythoninstallers "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" "github.com/paketo-buildpacks/python-installers/pkg/installers/uv" . "github.com/onsi/gomega" @@ -76,7 +76,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { Requires: []packit.BuildPlanRequirement{ { Name: uv.Uv, - Metadata: pythoninstallers.BuildPlanMetadata{ + Metadata: build.BuildPlanMetadata{ VersionSource: "BP_UV_VERSION", Version: "some-version", }, diff --git a/run/main.go b/run/main.go index 8bbe13e..c343659 100644 --- a/run/main.go +++ b/run/main.go @@ -16,7 +16,8 @@ import ( "github.com/paketo-buildpacks/packit/v2/scribe" pythoninstallers "github.com/paketo-buildpacks/python-installers" - pkgcommon "github.com/paketo-buildpacks/python-installers/pkg/installers/common" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom" miniconda "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda" pip "github.com/paketo-buildpacks/python-installers/pkg/installers/pip" pipenv "github.com/paketo-buildpacks/python-installers/pkg/installers/pipenv" @@ -28,8 +29,8 @@ import ( func main() { logger := scribe.NewEmitter(os.Stdout).WithLevel(os.Getenv("BP_LOG_LEVEL")) - buildParameters := pkgcommon.CommonBuildParameters{ - SbomGenerator: pkgcommon.Generator{}, + buildParameters := build.CommonBuildParameters{ + SbomGenerator: sbom.Generator{}, Clock: chronos.DefaultClock, Logger: logger, } From 779b444c1543141969da45cf195b0f0275a15b93 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Fri, 20 Feb 2026 22:00:56 +0100 Subject: [PATCH 4/9] chore: move sbom generate comment to correct file --- pkg/installers/common/sbom/sbom.go | 2 ++ pkg/installers/miniconda/build.go | 1 - pkg/installers/pip/build.go | 1 - pkg/installers/pipenv/build.go | 1 - pkg/installers/pixi/build.go | 1 - pkg/installers/poetry/build.go | 1 - pkg/installers/uv/build.go | 1 - 7 files changed, 2 insertions(+), 6 deletions(-) diff --git a/pkg/installers/common/sbom/sbom.go b/pkg/installers/common/sbom/sbom.go index 2df24eb..adb9ed2 100644 --- a/pkg/installers/common/sbom/sbom.go +++ b/pkg/installers/common/sbom/sbom.go @@ -10,6 +10,8 @@ import ( "github.com/paketo-buildpacks/packit/v2/sbom" ) +//go:generate faux --interface SBOMGenerator --output fakes/sbom_generator.go + type SBOMGenerator interface { GenerateFromDependency(dependency postal.Dependency, path string) (sbom.SBOM, error) } diff --git a/pkg/installers/miniconda/build.go b/pkg/installers/miniconda/build.go index 8c3d861..cb0af9d 100644 --- a/pkg/installers/miniconda/build.go +++ b/pkg/installers/miniconda/build.go @@ -20,7 +20,6 @@ import ( //go:generate faux --interface DependencyManager --output fakes/dependency_manager.go //go:generate faux --interface Runner --output fakes/runner.go -//go:generate faux --interface SBOMGenerator --output fakes/sbom_generator.go // DependencyManager defines the interface for picking the best matching // dependency and installing it. diff --git a/pkg/installers/pip/build.go b/pkg/installers/pip/build.go index 5980c90..1a78a9f 100644 --- a/pkg/installers/pip/build.go +++ b/pkg/installers/pip/build.go @@ -22,7 +22,6 @@ import ( //go:generate faux --interface DependencyManager --output fakes/dependency_manager.go //go:generate faux --interface InstallProcess --output fakes/install_process.go //go:generate faux --interface SitePackageProcess --output fakes/site_package_process.go -//go:generate faux --interface SBOMGenerator --output fakes/sbom_generator.go // DependencyManager defines the interface for picking the best matching // dependency and installing it. diff --git a/pkg/installers/pipenv/build.go b/pkg/installers/pipenv/build.go index 17a6387..c8bc693 100644 --- a/pkg/installers/pipenv/build.go +++ b/pkg/installers/pipenv/build.go @@ -21,7 +21,6 @@ import ( //go:generate faux --interface DependencyManager --output fakes/dependency_manager.go //go:generate faux --interface InstallProcess --output fakes/install_process.go //go:generate faux --interface SitePackageProcess --output fakes/site_package_process.go -//go:generate faux --interface SBOMGenerator --output fakes/sbom_generator.go // DependencyManager defines the interface for picking the best matching // dependency and installing it. diff --git a/pkg/installers/pixi/build.go b/pkg/installers/pixi/build.go index 52f7faf..ffeaf95 100644 --- a/pkg/installers/pixi/build.go +++ b/pkg/installers/pixi/build.go @@ -20,7 +20,6 @@ import ( //go:generate faux --interface DependencyManager --output fakes/dependency_manager.go //go:generate faux --interface Runner --output fakes/runner.go -//go:generate faux --interface SBOMGenerator --output fakes/sbom_generator.go // DependencyManager defines the interface for picking the best matching // dependency and installing it. diff --git a/pkg/installers/poetry/build.go b/pkg/installers/poetry/build.go index 1bcbda2..091b5b0 100644 --- a/pkg/installers/poetry/build.go +++ b/pkg/installers/poetry/build.go @@ -21,7 +21,6 @@ import ( //go:generate faux --interface DependencyManager --output fakes/dependency_manager.go //go:generate faux --interface InstallProcess --output fakes/install_process.go //go:generate faux --interface SitePackageProcess --output fakes/site_package_process.go -//go:generate faux --interface SBOMGenerator --output fakes/sbom_generator.go type DependencyManager interface { Resolve(path, id, version, stack string) (postal.Dependency, error) diff --git a/pkg/installers/uv/build.go b/pkg/installers/uv/build.go index 827ffd8..36afa5a 100644 --- a/pkg/installers/uv/build.go +++ b/pkg/installers/uv/build.go @@ -20,7 +20,6 @@ import ( //go:generate faux --interface DependencyManager --output fakes/dependency_manager.go //go:generate faux --interface Runner --output fakes/runner.go -//go:generate faux --interface SBOMGenerator --output fakes/sbom_generator.go // DependencyManager defines the interface for picking the best matching // dependency and installing it. From 440844731c5c4f949369b3bf97aa52f01882f5cb Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Fri, 20 Feb 2026 22:55:55 +0100 Subject: [PATCH 5/9] refactor: moved DependencyManager in own package This also unifies the various implementations. --- build_test.go | 27 +++--- .../common/dependency/dependency.go | 19 ++++ .../dependency}/fakes/dependency_manager.go | 0 pkg/installers/miniconda/build.go | 13 +-- pkg/installers/miniconda/build_test.go | 5 +- pkg/installers/pip/build.go | 13 +-- pkg/installers/pip/build_test.go | 5 +- .../pip/fakes/dependency_manager.go | 92 ------------------ pkg/installers/pipenv/build.go | 12 +-- pkg/installers/pipenv/build_test.go | 5 +- .../pipenv/fakes/dependency_manager.go | 65 ------------- pkg/installers/pixi/build.go | 13 +-- pkg/installers/pixi/build_test.go | 5 +- .../pixi/fakes/dependency_manager.go | 93 ------------------- pkg/installers/poetry/build.go | 14 +-- pkg/installers/poetry/build_test.go | 5 +- .../poetry/fakes/dependency_manager.go | 65 ------------- pkg/installers/uv/build.go | 13 +-- pkg/installers/uv/build_test.go | 5 +- pkg/installers/uv/fakes/dependency_manager.go | 93 ------------------- 20 files changed, 63 insertions(+), 499 deletions(-) create mode 100644 pkg/installers/common/dependency/dependency.go rename pkg/installers/{miniconda => common/dependency}/fakes/dependency_manager.go (100%) delete mode 100644 pkg/installers/pip/fakes/dependency_manager.go delete mode 100644 pkg/installers/pipenv/fakes/dependency_manager.go delete mode 100644 pkg/installers/pixi/fakes/dependency_manager.go delete mode 100644 pkg/installers/poetry/fakes/dependency_manager.go delete mode 100644 pkg/installers/uv/fakes/dependency_manager.go diff --git a/build_test.go b/build_test.go index 9246971..5fc4e67 100644 --- a/build_test.go +++ b/build_test.go @@ -23,6 +23,7 @@ import ( pythoninstallers "github.com/paketo-buildpacks/python-installers" "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + dependencyfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency/fakes" sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" miniconda "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda" minicondafakes "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda/fakes" @@ -61,33 +62,33 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { // common sbomGenerator *sbomfakes.SBOMGenerator - // dependencyManager *pipfakes.DependencyManager + // dependencyManager *dependencyfakes.DependencyManager // conda - minicondaDependencyManager *minicondafakes.DependencyManager + minicondaDependencyManager *dependencyfakes.DependencyManager runner *minicondafakes.Runner // pip - pipDependencyManager *pipfakes.DependencyManager + pipDependencyManager *dependencyfakes.DependencyManager pipInstallProcess *pipfakes.InstallProcess pipSitePackageProcess *pipfakes.SitePackageProcess // pipenv - pipenvDependencyManager *pipenvfakes.DependencyManager + pipenvDependencyManager *dependencyfakes.DependencyManager pipenvProcess *pipenvfakes.InstallProcess pipenvSitePackageProcess *pipenvfakes.SitePackageProcess // poetry - poetryDependencyManager *poetryfakes.DependencyManager + poetryDependencyManager *dependencyfakes.DependencyManager poetryProcess *poetryfakes.InstallProcess poetrySitePackageProcess *poetryfakes.SitePackageProcess // uv - uvDependencyManager *uvfakes.DependencyManager + uvDependencyManager *dependencyfakes.DependencyManager uvInstallProcess *uvfakes.InstallProcess // pixi - pixiDependencyManager *pixifakes.DependencyManager + pixiDependencyManager *dependencyfakes.DependencyManager pixiInstallProcess *pixifakes.InstallProcess buildParameters build.CommonBuildParameters @@ -107,7 +108,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { sbomGenerator.GenerateFromDependencyCall.Returns.SBOM = sbom.SBOM{} // miniconda - minicondaDependencyManager = &minicondafakes.DependencyManager{} + minicondaDependencyManager = &dependencyfakes.DependencyManager{} minicondaDependencyManager.ResolveCall.Returns.Dependency = postal.Dependency{ ID: "miniconda3", Name: "miniconda3-dependency-name", @@ -135,7 +136,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { runner = &minicondafakes.Runner{} // pip - pipDependencyManager = &pipfakes.DependencyManager{} + pipDependencyManager = &dependencyfakes.DependencyManager{} pipDependencyManager.ResolveCall.Returns.Dependency = postal.Dependency{ ID: "pip", Name: "Pip", @@ -172,7 +173,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { pipSitePackageProcess.ExecuteCall.Returns.String = filepath.Join(layersDir, "pip", "lib", "python1.23", "site-packages") // pipenv - pipenvDependencyManager = &pipenvfakes.DependencyManager{} + pipenvDependencyManager = &dependencyfakes.DependencyManager{} pipenvDependencyManager.ResolveCall.Returns.Dependency = postal.Dependency{ ID: "pipenv", Name: "pipenv-dependency-name", @@ -202,7 +203,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { pipenvSitePackageProcess.ExecuteCall.Returns.String = filepath.Join(layersDir, "pipenv", "lib", "python3.8", "site-packages") // poetry - poetryDependencyManager = &poetryfakes.DependencyManager{} + poetryDependencyManager = &dependencyfakes.DependencyManager{} poetryDependencyManager.ResolveCall.Returns.Dependency = postal.Dependency{ ID: "poetry", Name: "poetry-dependency-name", @@ -231,7 +232,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { poetrySitePackageProcess.ExecuteCall.Returns.String = filepath.Join(layersDir, "poetry", "lib", "python3.8", "site-packages") // uv - uvDependencyManager = &uvfakes.DependencyManager{} + uvDependencyManager = &dependencyfakes.DependencyManager{} uvDependencyManager.ResolveCall.Returns.Dependency = postal.Dependency{ ID: "uv", Name: "uv-dependency-name", @@ -259,7 +260,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { uvInstallProcess = &uvfakes.InstallProcess{} // pixi - pixiDependencyManager = &pixifakes.DependencyManager{} + pixiDependencyManager = &dependencyfakes.DependencyManager{} pixiDependencyManager.ResolveCall.Returns.Dependency = postal.Dependency{ ID: "pixi", Name: "pixi-dependency-name", diff --git a/pkg/installers/common/dependency/dependency.go b/pkg/installers/common/dependency/dependency.go new file mode 100644 index 0000000..c4aeaf7 --- /dev/null +++ b/pkg/installers/common/dependency/dependency.go @@ -0,0 +1,19 @@ +// SPDX-FileCopyrightText: © 2026 Idiap Research Institute +// SPDX-FileContributor: Samuel Gaist +// +// SPDX-License-Identifier: Apache-2.0 + +package dependency + +import ( + "github.com/paketo-buildpacks/packit/v2" + "github.com/paketo-buildpacks/packit/v2/postal" +) + +// DependencyManager defines the interface for picking the best matching +// dependency and installing it. +type DependencyManager interface { + Resolve(path, id, version, stack string) (postal.Dependency, error) + Deliver(dependency postal.Dependency, cnbPath, destinationPath, platformPath string) error + GenerateBillOfMaterials(dependencies ...postal.Dependency) []packit.BOMEntry +} diff --git a/pkg/installers/miniconda/fakes/dependency_manager.go b/pkg/installers/common/dependency/fakes/dependency_manager.go similarity index 100% rename from pkg/installers/miniconda/fakes/dependency_manager.go rename to pkg/installers/common/dependency/fakes/dependency_manager.go diff --git a/pkg/installers/miniconda/build.go b/pkg/installers/miniconda/build.go index cb0af9d..5ff28ee 100644 --- a/pkg/installers/miniconda/build.go +++ b/pkg/installers/miniconda/build.go @@ -12,23 +12,14 @@ import ( "github.com/paketo-buildpacks/packit/v2" "github.com/paketo-buildpacks/packit/v2/cargo" "github.com/paketo-buildpacks/packit/v2/draft" - "github.com/paketo-buildpacks/packit/v2/postal" "github.com/paketo-buildpacks/packit/v2/sbom" "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency" ) -//go:generate faux --interface DependencyManager --output fakes/dependency_manager.go //go:generate faux --interface Runner --output fakes/runner.go -// DependencyManager defines the interface for picking the best matching -// dependency and installing it. -type DependencyManager interface { - Resolve(path, id, version, stack string) (postal.Dependency, error) - Deliver(dependency postal.Dependency, cnbPath, destinationPath, platformPath string) error - GenerateBillOfMaterials(dependencies ...postal.Dependency) []packit.BOMEntry -} - // Runner defines the interface for invoking the miniconda script downloaded as a dependency. type Runner interface { Run(runPath, layerPath string) error @@ -45,7 +36,7 @@ func GetEnvOrDefault(key, defaultValue string) string { // CondaBuildParameters encapsulates the conda specific parameters for the // Build function type CondaBuildParameters struct { - DependencyManager DependencyManager + DependencyManager dependency.DependencyManager Runner Runner } diff --git a/pkg/installers/miniconda/build_test.go b/pkg/installers/miniconda/build_test.go index 39ebf9e..014326f 100644 --- a/pkg/installers/miniconda/build_test.go +++ b/pkg/installers/miniconda/build_test.go @@ -15,6 +15,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/chronos" "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + dependencyfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency/fakes" sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda" @@ -39,7 +40,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { buffer *bytes.Buffer - dependencyManager *fakes.DependencyManager + dependencyManager *dependencyfakes.DependencyManager runner *fakes.Runner sbomGenerator *sbomfakes.SBOMGenerator @@ -55,7 +56,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { cnbDir, err = os.MkdirTemp("", "cnb") Expect(err).NotTo(HaveOccurred()) - dependencyManager = &fakes.DependencyManager{} + dependencyManager = &dependencyfakes.DependencyManager{} dependencyManager.ResolveCall.Returns.Dependency = postal.Dependency{ ID: "miniconda3", Name: "miniconda3-dependency-name", diff --git a/pkg/installers/pip/build.go b/pkg/installers/pip/build.go index 1a78a9f..58107ba 100644 --- a/pkg/installers/pip/build.go +++ b/pkg/installers/pip/build.go @@ -13,24 +13,15 @@ import ( "github.com/paketo-buildpacks/packit/v2" "github.com/paketo-buildpacks/packit/v2/cargo" "github.com/paketo-buildpacks/packit/v2/draft" - "github.com/paketo-buildpacks/packit/v2/postal" "github.com/paketo-buildpacks/packit/v2/sbom" "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency" ) -//go:generate faux --interface DependencyManager --output fakes/dependency_manager.go //go:generate faux --interface InstallProcess --output fakes/install_process.go //go:generate faux --interface SitePackageProcess --output fakes/site_package_process.go -// DependencyManager defines the interface for picking the best matching -// dependency and installing it. -type DependencyManager interface { - Resolve(path, id, version, stack string) (postal.Dependency, error) - Deliver(dependency postal.Dependency, cnbPath, destinationPath, platformPath string) error - GenerateBillOfMaterials(dependencies ...postal.Dependency) []packit.BOMEntry -} - // InstallProcess defines the interface for installing the pip dependency into a layer. type InstallProcess interface { Execute(srcPath, targetLayerPath string) error @@ -44,7 +35,7 @@ type SitePackageProcess interface { // PipBuildParameters encapsulates the pip specific parameters for the // Build function type PipBuildParameters struct { - DependencyManager DependencyManager + DependencyManager dependency.DependencyManager InstallProcess InstallProcess SitePackageProcess SitePackageProcess } diff --git a/pkg/installers/pip/build_test.go b/pkg/installers/pip/build_test.go index 6b7ef41..69e2dbd 100644 --- a/pkg/installers/pip/build_test.go +++ b/pkg/installers/pip/build_test.go @@ -23,6 +23,7 @@ import ( "github.com/sclevine/spec" "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + dependencyfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency/fakes" sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/pip" @@ -38,7 +39,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { layersDir string cnbDir string - dependencyManager *fakes.DependencyManager + dependencyManager *dependencyfakes.DependencyManager installProcess *fakes.InstallProcess sitePackageProcess *fakes.SitePackageProcess sbomGenerator *sbomfakes.SBOMGenerator @@ -59,7 +60,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { cnbDir, err = os.MkdirTemp("", "cnb") Expect(err).NotTo(HaveOccurred()) - dependencyManager = &fakes.DependencyManager{} + dependencyManager = &dependencyfakes.DependencyManager{} dependencyManager.ResolveCall.Returns.Dependency = postal.Dependency{ ID: "pip", Name: "Pip", diff --git a/pkg/installers/pip/fakes/dependency_manager.go b/pkg/installers/pip/fakes/dependency_manager.go deleted file mode 100644 index c42c9f6..0000000 --- a/pkg/installers/pip/fakes/dependency_manager.go +++ /dev/null @@ -1,92 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2013-Present CloudFoundry.org Foundation, Inc. All Rights Reserved. -// -// SPDX-License-Identifier: Apache-2.0 - -package fakes - -import ( - "sync" - - packit "github.com/paketo-buildpacks/packit/v2" - "github.com/paketo-buildpacks/packit/v2/postal" -) - -type DependencyManager struct { - DeliverCall struct { - mutex sync.Mutex - CallCount int - Receives struct { - Dependency postal.Dependency - CnbPath string - DestinationPath string - PlatformPath string - } - Returns struct { - Error error - } - Stub func(postal.Dependency, string, string, string) error - } - GenerateBillOfMaterialsCall struct { - mutex sync.Mutex - CallCount int - Receives struct { - Dependencies []postal.Dependency - } - Returns struct { - BOMEntrySlice []packit.BOMEntry - } - Stub func(...postal.Dependency) []packit.BOMEntry - } - ResolveCall struct { - mutex sync.Mutex - CallCount int - Receives struct { - Path string - Id string - Version string - Stack string - } - Returns struct { - Dependency postal.Dependency - Error error - } - Stub func(string, string, string, string) (postal.Dependency, error) - } -} - -func (f *DependencyManager) Deliver(param1 postal.Dependency, param2 string, param3 string, param4 string) error { - f.DeliverCall.mutex.Lock() - defer f.DeliverCall.mutex.Unlock() - f.DeliverCall.CallCount++ - f.DeliverCall.Receives.Dependency = param1 - f.DeliverCall.Receives.CnbPath = param2 - f.DeliverCall.Receives.DestinationPath = param3 - f.DeliverCall.Receives.PlatformPath = param4 - if f.DeliverCall.Stub != nil { - return f.DeliverCall.Stub(param1, param2, param3, param4) - } - return f.DeliverCall.Returns.Error -} -func (f *DependencyManager) GenerateBillOfMaterials(param1 ...postal.Dependency) []packit.BOMEntry { - f.GenerateBillOfMaterialsCall.mutex.Lock() - defer f.GenerateBillOfMaterialsCall.mutex.Unlock() - f.GenerateBillOfMaterialsCall.CallCount++ - f.GenerateBillOfMaterialsCall.Receives.Dependencies = param1 - if f.GenerateBillOfMaterialsCall.Stub != nil { - return f.GenerateBillOfMaterialsCall.Stub(param1...) - } - return f.GenerateBillOfMaterialsCall.Returns.BOMEntrySlice -} -func (f *DependencyManager) Resolve(param1 string, param2 string, param3 string, param4 string) (postal.Dependency, error) { - f.ResolveCall.mutex.Lock() - defer f.ResolveCall.mutex.Unlock() - f.ResolveCall.CallCount++ - f.ResolveCall.Receives.Path = param1 - f.ResolveCall.Receives.Id = param2 - f.ResolveCall.Receives.Version = param3 - f.ResolveCall.Receives.Stack = param4 - if f.ResolveCall.Stub != nil { - return f.ResolveCall.Stub(param1, param2, param3, param4) - } - return f.ResolveCall.Returns.Dependency, f.ResolveCall.Returns.Error -} diff --git a/pkg/installers/pipenv/build.go b/pkg/installers/pipenv/build.go index c8bc693..afd585e 100644 --- a/pkg/installers/pipenv/build.go +++ b/pkg/installers/pipenv/build.go @@ -12,23 +12,15 @@ import ( "github.com/paketo-buildpacks/packit/v2" "github.com/paketo-buildpacks/packit/v2/draft" - "github.com/paketo-buildpacks/packit/v2/postal" "github.com/paketo-buildpacks/packit/v2/sbom" "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency" ) -//go:generate faux --interface DependencyManager --output fakes/dependency_manager.go //go:generate faux --interface InstallProcess --output fakes/install_process.go //go:generate faux --interface SitePackageProcess --output fakes/site_package_process.go -// DependencyManager defines the interface for picking the best matching -// dependency and installing it. -type DependencyManager interface { - Resolve(path, id, version, stack string) (postal.Dependency, error) - GenerateBillOfMaterials(dependencies ...postal.Dependency) []packit.BOMEntry -} - // InstallProcess defines the interface for installing the pipenv dependency into a layer. type InstallProcess interface { Execute(version, destLayerPath, pipLayerPath string) error @@ -42,7 +34,7 @@ type SitePackageProcess interface { // PipEnvBuildParameters encapsulates the pip specific parameters for the // Build function type PipEnvBuildParameters struct { - DependencyManager DependencyManager + DependencyManager dependency.DependencyManager InstallProcess InstallProcess SitePackageProcess SitePackageProcess } diff --git a/pkg/installers/pipenv/build_test.go b/pkg/installers/pipenv/build_test.go index 668086a..00994f4 100644 --- a/pkg/installers/pipenv/build_test.go +++ b/pkg/installers/pipenv/build_test.go @@ -23,6 +23,7 @@ import ( "github.com/sclevine/spec" "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + dependencyfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency/fakes" sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/pipenv" "github.com/paketo-buildpacks/python-installers/pkg/installers/pipenv/fakes" @@ -37,7 +38,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { layersDir string cnbDir string - dependencyManager *fakes.DependencyManager + dependencyManager *dependencyfakes.DependencyManager installProcess *fakes.InstallProcess siteProcess *fakes.SitePackageProcess sbomGenerator *sbomfakes.SBOMGenerator @@ -54,7 +55,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { layersDir = t.TempDir() cnbDir = t.TempDir() - dependencyManager = &fakes.DependencyManager{} + dependencyManager = &dependencyfakes.DependencyManager{} dependencyManager.ResolveCall.Returns.Dependency = postal.Dependency{ ID: "pipenv", Name: "pipenv-dependency-name", diff --git a/pkg/installers/pipenv/fakes/dependency_manager.go b/pkg/installers/pipenv/fakes/dependency_manager.go deleted file mode 100644 index e7b5ec6..0000000 --- a/pkg/installers/pipenv/fakes/dependency_manager.go +++ /dev/null @@ -1,65 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2013-Present CloudFoundry.org Foundation, Inc. All Rights Reserved. -// -// SPDX-License-Identifier: Apache-2.0 - -package fakes - -import ( - "sync" - - "github.com/paketo-buildpacks/packit/v2" - "github.com/paketo-buildpacks/packit/v2/postal" -) - -type DependencyManager struct { - GenerateBillOfMaterialsCall struct { - mutex sync.Mutex - CallCount int - Receives struct { - Dependencies []postal.Dependency - } - Returns struct { - BOMEntrySlice []packit.BOMEntry - } - Stub func(...postal.Dependency) []packit.BOMEntry - } - ResolveCall struct { - mutex sync.Mutex - CallCount int - Receives struct { - Path string - Id string - Version string - Stack string - } - Returns struct { - Dependency postal.Dependency - Error error - } - Stub func(string, string, string, string) (postal.Dependency, error) - } -} - -func (f *DependencyManager) GenerateBillOfMaterials(param1 ...postal.Dependency) []packit.BOMEntry { - f.GenerateBillOfMaterialsCall.mutex.Lock() - defer f.GenerateBillOfMaterialsCall.mutex.Unlock() - f.GenerateBillOfMaterialsCall.CallCount++ - f.GenerateBillOfMaterialsCall.Receives.Dependencies = param1 - if f.GenerateBillOfMaterialsCall.Stub != nil { - return f.GenerateBillOfMaterialsCall.Stub(param1...) - } - return f.GenerateBillOfMaterialsCall.Returns.BOMEntrySlice -} -func (f *DependencyManager) Resolve(param1 string, param2 string, param3 string, param4 string) (postal.Dependency, error) { - f.ResolveCall.mutex.Lock() - defer f.ResolveCall.mutex.Unlock() - f.ResolveCall.CallCount++ - f.ResolveCall.Receives.Path = param1 - f.ResolveCall.Receives.Id = param2 - f.ResolveCall.Receives.Version = param3 - f.ResolveCall.Receives.Stack = param4 - if f.ResolveCall.Stub != nil { - return f.ResolveCall.Stub(param1, param2, param3, param4) - } - return f.ResolveCall.Returns.Dependency, f.ResolveCall.Returns.Error -} diff --git a/pkg/installers/pixi/build.go b/pkg/installers/pixi/build.go index ffeaf95..f91cae7 100644 --- a/pkg/installers/pixi/build.go +++ b/pkg/installers/pixi/build.go @@ -12,23 +12,14 @@ import ( "github.com/paketo-buildpacks/packit/v2" "github.com/paketo-buildpacks/packit/v2/cargo" "github.com/paketo-buildpacks/packit/v2/draft" - "github.com/paketo-buildpacks/packit/v2/postal" "github.com/paketo-buildpacks/packit/v2/sbom" "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency" ) -//go:generate faux --interface DependencyManager --output fakes/dependency_manager.go //go:generate faux --interface Runner --output fakes/runner.go -// DependencyManager defines the interface for picking the best matching -// dependency and installing it. -type DependencyManager interface { - Resolve(path, id, version, stack string) (postal.Dependency, error) - Deliver(dependency postal.Dependency, cnbPath, destinationPath, platformPath string) error - GenerateBillOfMaterials(dependencies ...postal.Dependency) []packit.BOMEntry -} - // InstallProcess defines the interface for installing the poetry dependency into a layer. type InstallProcess interface { Execute(sourcePath, targetLayerPath, dependencyName string) error @@ -37,7 +28,7 @@ type InstallProcess interface { // PixiBuildParameters encapsulates the pixi specific parameters for the // Build function type PixiBuildParameters struct { - DependencyManager DependencyManager + DependencyManager dependency.DependencyManager InstallProcess InstallProcess } diff --git a/pkg/installers/pixi/build_test.go b/pkg/installers/pixi/build_test.go index 2e9504d..dd17f90 100644 --- a/pkg/installers/pixi/build_test.go +++ b/pkg/installers/pixi/build_test.go @@ -16,6 +16,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/chronos" "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + dependencyfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency/fakes" sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/pixi" @@ -40,7 +41,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { buffer *bytes.Buffer - dependencyManager *fakes.DependencyManager + dependencyManager *dependencyfakes.DependencyManager installProcess *fakes.InstallProcess sbomGenerator *sbomfakes.SBOMGenerator @@ -56,7 +57,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { cnbDir, err = os.MkdirTemp("", "cnb") Expect(err).NotTo(HaveOccurred()) - dependencyManager = &fakes.DependencyManager{} + dependencyManager = &dependencyfakes.DependencyManager{} dependencyManager.ResolveCall.Returns.Dependency = postal.Dependency{ ID: "pixi", Name: "pixi-dependency-name", diff --git a/pkg/installers/pixi/fakes/dependency_manager.go b/pkg/installers/pixi/fakes/dependency_manager.go deleted file mode 100644 index 3b6a100..0000000 --- a/pkg/installers/pixi/fakes/dependency_manager.go +++ /dev/null @@ -1,93 +0,0 @@ -// SPDX-FileCopyrightText: © 2026 Idiap Research Institute -// SPDX-FileContributor: Samuel Gaist -// -// SPDX-License-Identifier: Apache-2.0 - -package fakes - -import ( - "sync" - - "github.com/paketo-buildpacks/packit/v2" - "github.com/paketo-buildpacks/packit/v2/postal" -) - -type DependencyManager struct { - DeliverCall struct { - mutex sync.Mutex - CallCount int - Receives struct { - Dependency postal.Dependency - CnbPath string - DestinationPath string - PlatformPath string - } - Returns struct { - Error error - } - Stub func(postal.Dependency, string, string, string) error - } - GenerateBillOfMaterialsCall struct { - mutex sync.Mutex - CallCount int - Receives struct { - Dependencies []postal.Dependency - } - Returns struct { - BOMEntrySlice []packit.BOMEntry - } - Stub func(...postal.Dependency) []packit.BOMEntry - } - ResolveCall struct { - mutex sync.Mutex - CallCount int - Receives struct { - Path string - Id string - Version string - Stack string - } - Returns struct { - Dependency postal.Dependency - Error error - } - Stub func(string, string, string, string) (postal.Dependency, error) - } -} - -func (f *DependencyManager) Deliver(param1 postal.Dependency, param2 string, param3 string, param4 string) error { - f.DeliverCall.mutex.Lock() - defer f.DeliverCall.mutex.Unlock() - f.DeliverCall.CallCount++ - f.DeliverCall.Receives.Dependency = param1 - f.DeliverCall.Receives.CnbPath = param2 - f.DeliverCall.Receives.DestinationPath = param3 - f.DeliverCall.Receives.PlatformPath = param4 - if f.DeliverCall.Stub != nil { - return f.DeliverCall.Stub(param1, param2, param3, param4) - } - return f.DeliverCall.Returns.Error -} -func (f *DependencyManager) GenerateBillOfMaterials(param1 ...postal.Dependency) []packit.BOMEntry { - f.GenerateBillOfMaterialsCall.mutex.Lock() - defer f.GenerateBillOfMaterialsCall.mutex.Unlock() - f.GenerateBillOfMaterialsCall.CallCount++ - f.GenerateBillOfMaterialsCall.Receives.Dependencies = param1 - if f.GenerateBillOfMaterialsCall.Stub != nil { - return f.GenerateBillOfMaterialsCall.Stub(param1...) - } - return f.GenerateBillOfMaterialsCall.Returns.BOMEntrySlice -} -func (f *DependencyManager) Resolve(param1 string, param2 string, param3 string, param4 string) (postal.Dependency, error) { - f.ResolveCall.mutex.Lock() - defer f.ResolveCall.mutex.Unlock() - f.ResolveCall.CallCount++ - f.ResolveCall.Receives.Path = param1 - f.ResolveCall.Receives.Id = param2 - f.ResolveCall.Receives.Version = param3 - f.ResolveCall.Receives.Stack = param4 - if f.ResolveCall.Stub != nil { - return f.ResolveCall.Stub(param1, param2, param3, param4) - } - return f.ResolveCall.Returns.Dependency, f.ResolveCall.Returns.Error -} diff --git a/pkg/installers/poetry/build.go b/pkg/installers/poetry/build.go index 091b5b0..bb8ba67 100644 --- a/pkg/installers/poetry/build.go +++ b/pkg/installers/poetry/build.go @@ -12,21 +12,15 @@ import ( "github.com/paketo-buildpacks/packit/v2" "github.com/paketo-buildpacks/packit/v2/draft" - "github.com/paketo-buildpacks/packit/v2/postal" "github.com/paketo-buildpacks/packit/v2/sbom" "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency" ) -//go:generate faux --interface DependencyManager --output fakes/dependency_manager.go //go:generate faux --interface InstallProcess --output fakes/install_process.go //go:generate faux --interface SitePackageProcess --output fakes/site_package_process.go -type DependencyManager interface { - Resolve(path, id, version, stack string) (postal.Dependency, error) - GenerateBillOfMaterials(dependencies ...postal.Dependency) []packit.BOMEntry -} - // InstallProcess defines the interface for installing the poetry dependency into a layer. type InstallProcess interface { Execute(version, targetLayerPath, pipLayerPath string) error @@ -37,14 +31,10 @@ type SitePackageProcess interface { Execute(targetLayerPath string) (string, error) } -type SBOMGenerator interface { - GenerateFromDependency(dependency postal.Dependency, dir string) (sbom.SBOM, error) -} - // PoetryBuildParameters encapsulates the pip specific parameters for the // Build function type PoetryBuildParameters struct { - DependencyManager DependencyManager + DependencyManager dependency.DependencyManager InstallProcess InstallProcess SitePackageProcess SitePackageProcess } diff --git a/pkg/installers/poetry/build_test.go b/pkg/installers/poetry/build_test.go index f12d1f0..fe13feb 100644 --- a/pkg/installers/poetry/build_test.go +++ b/pkg/installers/poetry/build_test.go @@ -22,6 +22,7 @@ import ( "github.com/sclevine/spec" "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + dependencyfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency/fakes" sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/poetry" @@ -37,7 +38,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { layersDir string cnbDir string - dependencyManager *fakes.DependencyManager + dependencyManager *dependencyfakes.DependencyManager installProcess *fakes.InstallProcess siteProcess *fakes.SitePackageProcess sbomGenerator *sbomfakes.SBOMGenerator @@ -57,7 +58,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { Expect(err).NotTo(HaveOccurred()) // Legacy SBOM - dependencyManager = &fakes.DependencyManager{} + dependencyManager = &dependencyfakes.DependencyManager{} dependencyManager.ResolveCall.Returns.Dependency = postal.Dependency{ ID: "poetry", Name: "poetry-dependency-name", diff --git a/pkg/installers/poetry/fakes/dependency_manager.go b/pkg/installers/poetry/fakes/dependency_manager.go deleted file mode 100644 index e7b5ec6..0000000 --- a/pkg/installers/poetry/fakes/dependency_manager.go +++ /dev/null @@ -1,65 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2013-Present CloudFoundry.org Foundation, Inc. All Rights Reserved. -// -// SPDX-License-Identifier: Apache-2.0 - -package fakes - -import ( - "sync" - - "github.com/paketo-buildpacks/packit/v2" - "github.com/paketo-buildpacks/packit/v2/postal" -) - -type DependencyManager struct { - GenerateBillOfMaterialsCall struct { - mutex sync.Mutex - CallCount int - Receives struct { - Dependencies []postal.Dependency - } - Returns struct { - BOMEntrySlice []packit.BOMEntry - } - Stub func(...postal.Dependency) []packit.BOMEntry - } - ResolveCall struct { - mutex sync.Mutex - CallCount int - Receives struct { - Path string - Id string - Version string - Stack string - } - Returns struct { - Dependency postal.Dependency - Error error - } - Stub func(string, string, string, string) (postal.Dependency, error) - } -} - -func (f *DependencyManager) GenerateBillOfMaterials(param1 ...postal.Dependency) []packit.BOMEntry { - f.GenerateBillOfMaterialsCall.mutex.Lock() - defer f.GenerateBillOfMaterialsCall.mutex.Unlock() - f.GenerateBillOfMaterialsCall.CallCount++ - f.GenerateBillOfMaterialsCall.Receives.Dependencies = param1 - if f.GenerateBillOfMaterialsCall.Stub != nil { - return f.GenerateBillOfMaterialsCall.Stub(param1...) - } - return f.GenerateBillOfMaterialsCall.Returns.BOMEntrySlice -} -func (f *DependencyManager) Resolve(param1 string, param2 string, param3 string, param4 string) (postal.Dependency, error) { - f.ResolveCall.mutex.Lock() - defer f.ResolveCall.mutex.Unlock() - f.ResolveCall.CallCount++ - f.ResolveCall.Receives.Path = param1 - f.ResolveCall.Receives.Id = param2 - f.ResolveCall.Receives.Version = param3 - f.ResolveCall.Receives.Stack = param4 - if f.ResolveCall.Stub != nil { - return f.ResolveCall.Stub(param1, param2, param3, param4) - } - return f.ResolveCall.Returns.Dependency, f.ResolveCall.Returns.Error -} diff --git a/pkg/installers/uv/build.go b/pkg/installers/uv/build.go index 36afa5a..6a34114 100644 --- a/pkg/installers/uv/build.go +++ b/pkg/installers/uv/build.go @@ -12,23 +12,14 @@ import ( "github.com/paketo-buildpacks/packit/v2" "github.com/paketo-buildpacks/packit/v2/cargo" "github.com/paketo-buildpacks/packit/v2/draft" - "github.com/paketo-buildpacks/packit/v2/postal" "github.com/paketo-buildpacks/packit/v2/sbom" "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency" ) -//go:generate faux --interface DependencyManager --output fakes/dependency_manager.go //go:generate faux --interface Runner --output fakes/runner.go -// DependencyManager defines the interface for picking the best matching -// dependency and installing it. -type DependencyManager interface { - Resolve(path, id, version, stack string) (postal.Dependency, error) - Deliver(dependency postal.Dependency, cnbPath, destinationPath, platformPath string) error - GenerateBillOfMaterials(dependencies ...postal.Dependency) []packit.BOMEntry -} - // InstallProcess defines the interface for installing the uv dependency into a layer. type InstallProcess interface { Execute(sourcePath, targetLayerPath, dependencyName string) error @@ -37,7 +28,7 @@ type InstallProcess interface { // UvBuildParameters encapsulates the uv specific parameters for the // Build function type UvBuildParameters struct { - DependencyManager DependencyManager + DependencyManager dependency.DependencyManager InstallProcess InstallProcess } diff --git a/pkg/installers/uv/build_test.go b/pkg/installers/uv/build_test.go index 60e8e13..e0919a4 100644 --- a/pkg/installers/uv/build_test.go +++ b/pkg/installers/uv/build_test.go @@ -16,6 +16,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/chronos" "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + dependencyfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency/fakes" sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/uv" @@ -40,7 +41,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { buffer *bytes.Buffer - dependencyManager *fakes.DependencyManager + dependencyManager *dependencyfakes.DependencyManager installProcess *fakes.InstallProcess sbomGenerator *sbomfakes.SBOMGenerator @@ -56,7 +57,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) { cnbDir, err = os.MkdirTemp("", "cnb") Expect(err).NotTo(HaveOccurred()) - dependencyManager = &fakes.DependencyManager{} + dependencyManager = &dependencyfakes.DependencyManager{} dependencyManager.ResolveCall.Returns.Dependency = postal.Dependency{ ID: "uv", Name: "uv-dependency-name", diff --git a/pkg/installers/uv/fakes/dependency_manager.go b/pkg/installers/uv/fakes/dependency_manager.go deleted file mode 100644 index f321df1..0000000 --- a/pkg/installers/uv/fakes/dependency_manager.go +++ /dev/null @@ -1,93 +0,0 @@ -// SPDX-FileCopyrightText: © 2025 Idiap Research Institute -// SPDX-FileContributor: Samuel Gaist -// -// SPDX-License-Identifier: Apache-2.0 - -package fakes - -import ( - "sync" - - "github.com/paketo-buildpacks/packit/v2" - "github.com/paketo-buildpacks/packit/v2/postal" -) - -type DependencyManager struct { - DeliverCall struct { - mutex sync.Mutex - CallCount int - Receives struct { - Dependency postal.Dependency - CnbPath string - DestinationPath string - PlatformPath string - } - Returns struct { - Error error - } - Stub func(postal.Dependency, string, string, string) error - } - GenerateBillOfMaterialsCall struct { - mutex sync.Mutex - CallCount int - Receives struct { - Dependencies []postal.Dependency - } - Returns struct { - BOMEntrySlice []packit.BOMEntry - } - Stub func(...postal.Dependency) []packit.BOMEntry - } - ResolveCall struct { - mutex sync.Mutex - CallCount int - Receives struct { - Path string - Id string - Version string - Stack string - } - Returns struct { - Dependency postal.Dependency - Error error - } - Stub func(string, string, string, string) (postal.Dependency, error) - } -} - -func (f *DependencyManager) Deliver(param1 postal.Dependency, param2 string, param3 string, param4 string) error { - f.DeliverCall.mutex.Lock() - defer f.DeliverCall.mutex.Unlock() - f.DeliverCall.CallCount++ - f.DeliverCall.Receives.Dependency = param1 - f.DeliverCall.Receives.CnbPath = param2 - f.DeliverCall.Receives.DestinationPath = param3 - f.DeliverCall.Receives.PlatformPath = param4 - if f.DeliverCall.Stub != nil { - return f.DeliverCall.Stub(param1, param2, param3, param4) - } - return f.DeliverCall.Returns.Error -} -func (f *DependencyManager) GenerateBillOfMaterials(param1 ...postal.Dependency) []packit.BOMEntry { - f.GenerateBillOfMaterialsCall.mutex.Lock() - defer f.GenerateBillOfMaterialsCall.mutex.Unlock() - f.GenerateBillOfMaterialsCall.CallCount++ - f.GenerateBillOfMaterialsCall.Receives.Dependencies = param1 - if f.GenerateBillOfMaterialsCall.Stub != nil { - return f.GenerateBillOfMaterialsCall.Stub(param1...) - } - return f.GenerateBillOfMaterialsCall.Returns.BOMEntrySlice -} -func (f *DependencyManager) Resolve(param1 string, param2 string, param3 string, param4 string) (postal.Dependency, error) { - f.ResolveCall.mutex.Lock() - defer f.ResolveCall.mutex.Unlock() - f.ResolveCall.CallCount++ - f.ResolveCall.Receives.Path = param1 - f.ResolveCall.Receives.Id = param2 - f.ResolveCall.Receives.Version = param3 - f.ResolveCall.Receives.Stack = param4 - if f.ResolveCall.Stub != nil { - return f.ResolveCall.Stub(param1, param2, param3, param4) - } - return f.ResolveCall.Returns.Dependency, f.ResolveCall.Returns.Error -} From 694879c278e760afdb53ab9406df4a549d59ff3a Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Fri, 20 Feb 2026 23:15:33 +0100 Subject: [PATCH 6/9] refactor: move Executable to own package --- .../common/executable/executable.go | 16 +++++++++ .../executable}/fakes/executable.go | 0 .../miniconda/script_runner_test.go | 2 +- pkg/installers/pip/fakes/executable.go | 36 ------------------- .../pip/pip_install_process_test.go | 2 +- pkg/installers/pip/site_process_test.go | 2 +- pkg/installers/pipenv/fakes/executable.go | 36 ------------------- .../pipenv/pipenv_install_process_test.go | 2 +- pkg/installers/pipenv/site_process_test.go | 2 +- pkg/installers/poetry/fakes/executable.go | 36 ------------------- .../poetry/poetry_install_process_test.go | 2 +- pkg/installers/poetry/site_process_test.go | 2 +- 12 files changed, 23 insertions(+), 115 deletions(-) create mode 100644 pkg/installers/common/executable/executable.go rename pkg/installers/{miniconda => common/executable}/fakes/executable.go (100%) delete mode 100644 pkg/installers/pip/fakes/executable.go delete mode 100644 pkg/installers/pipenv/fakes/executable.go delete mode 100644 pkg/installers/poetry/fakes/executable.go diff --git a/pkg/installers/common/executable/executable.go b/pkg/installers/common/executable/executable.go new file mode 100644 index 0000000..86a1c46 --- /dev/null +++ b/pkg/installers/common/executable/executable.go @@ -0,0 +1,16 @@ +// SPDX-FileCopyrightText: Copyright (c) 2013-Present CloudFoundry.org Foundation, Inc. All Rights Reserved. +// +// SPDX-License-Identifier: Apache-2.0 + +package executable + +import ( + "github.com/paketo-buildpacks/packit/v2/pexec" +) + +//go:generate faux --interface Executable --output fakes/executable.go + +// Executable defines the interface for invoking an executable. +type Executable interface { + Execute(pexec.Execution) error +} diff --git a/pkg/installers/miniconda/fakes/executable.go b/pkg/installers/common/executable/fakes/executable.go similarity index 100% rename from pkg/installers/miniconda/fakes/executable.go rename to pkg/installers/common/executable/fakes/executable.go diff --git a/pkg/installers/miniconda/script_runner_test.go b/pkg/installers/miniconda/script_runner_test.go index f556038..476f8a4 100644 --- a/pkg/installers/miniconda/script_runner_test.go +++ b/pkg/installers/miniconda/script_runner_test.go @@ -12,8 +12,8 @@ import ( "github.com/sclevine/spec" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/executable/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda" - "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda/fakes" . "github.com/onsi/gomega" ) diff --git a/pkg/installers/pip/fakes/executable.go b/pkg/installers/pip/fakes/executable.go deleted file mode 100644 index 49bf278..0000000 --- a/pkg/installers/pip/fakes/executable.go +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2013-Present CloudFoundry.org Foundation, Inc. All Rights Reserved. -// -// SPDX-License-Identifier: Apache-2.0 - -package fakes - -import ( - "sync" - - "github.com/paketo-buildpacks/packit/v2/pexec" -) - -type Executable struct { - ExecuteCall struct { - mutex sync.Mutex - CallCount int - Receives struct { - Execution pexec.Execution - } - Returns struct { - Error error - } - Stub func(pexec.Execution) error - } -} - -func (f *Executable) Execute(param1 pexec.Execution) error { - f.ExecuteCall.mutex.Lock() - defer f.ExecuteCall.mutex.Unlock() - f.ExecuteCall.CallCount++ - f.ExecuteCall.Receives.Execution = param1 - if f.ExecuteCall.Stub != nil { - return f.ExecuteCall.Stub(param1) - } - return f.ExecuteCall.Returns.Error -} diff --git a/pkg/installers/pip/pip_install_process_test.go b/pkg/installers/pip/pip_install_process_test.go index abfddcc..3b4c11c 100644 --- a/pkg/installers/pip/pip_install_process_test.go +++ b/pkg/installers/pip/pip_install_process_test.go @@ -13,8 +13,8 @@ import ( "github.com/paketo-buildpacks/packit/v2/pexec" "github.com/sclevine/spec" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/executable/fakes" pip "github.com/paketo-buildpacks/python-installers/pkg/installers/pip" - "github.com/paketo-buildpacks/python-installers/pkg/installers/pip/fakes" . "github.com/onsi/gomega" ) diff --git a/pkg/installers/pip/site_process_test.go b/pkg/installers/pip/site_process_test.go index b8146f5..9880f0d 100644 --- a/pkg/installers/pip/site_process_test.go +++ b/pkg/installers/pip/site_process_test.go @@ -14,8 +14,8 @@ import ( "github.com/paketo-buildpacks/packit/v2/pexec" "github.com/sclevine/spec" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/executable/fakes" pip "github.com/paketo-buildpacks/python-installers/pkg/installers/pip" - "github.com/paketo-buildpacks/python-installers/pkg/installers/pip/fakes" . "github.com/onsi/gomega" ) diff --git a/pkg/installers/pipenv/fakes/executable.go b/pkg/installers/pipenv/fakes/executable.go deleted file mode 100644 index 49bf278..0000000 --- a/pkg/installers/pipenv/fakes/executable.go +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2013-Present CloudFoundry.org Foundation, Inc. All Rights Reserved. -// -// SPDX-License-Identifier: Apache-2.0 - -package fakes - -import ( - "sync" - - "github.com/paketo-buildpacks/packit/v2/pexec" -) - -type Executable struct { - ExecuteCall struct { - mutex sync.Mutex - CallCount int - Receives struct { - Execution pexec.Execution - } - Returns struct { - Error error - } - Stub func(pexec.Execution) error - } -} - -func (f *Executable) Execute(param1 pexec.Execution) error { - f.ExecuteCall.mutex.Lock() - defer f.ExecuteCall.mutex.Unlock() - f.ExecuteCall.CallCount++ - f.ExecuteCall.Receives.Execution = param1 - if f.ExecuteCall.Stub != nil { - return f.ExecuteCall.Stub(param1) - } - return f.ExecuteCall.Returns.Error -} diff --git a/pkg/installers/pipenv/pipenv_install_process_test.go b/pkg/installers/pipenv/pipenv_install_process_test.go index 8ed5033..7277353 100644 --- a/pkg/installers/pipenv/pipenv_install_process_test.go +++ b/pkg/installers/pipenv/pipenv_install_process_test.go @@ -14,8 +14,8 @@ import ( "github.com/paketo-buildpacks/packit/v2/pexec" "github.com/sclevine/spec" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/executable/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/pipenv" - "github.com/paketo-buildpacks/python-installers/pkg/installers/pipenv/fakes" . "github.com/onsi/gomega" ) diff --git a/pkg/installers/pipenv/site_process_test.go b/pkg/installers/pipenv/site_process_test.go index 1eb67b9..905be99 100644 --- a/pkg/installers/pipenv/site_process_test.go +++ b/pkg/installers/pipenv/site_process_test.go @@ -14,8 +14,8 @@ import ( "github.com/paketo-buildpacks/packit/v2/pexec" "github.com/sclevine/spec" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/executable/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/pipenv" - "github.com/paketo-buildpacks/python-installers/pkg/installers/pipenv/fakes" . "github.com/onsi/gomega" ) diff --git a/pkg/installers/poetry/fakes/executable.go b/pkg/installers/poetry/fakes/executable.go deleted file mode 100644 index 49bf278..0000000 --- a/pkg/installers/poetry/fakes/executable.go +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2013-Present CloudFoundry.org Foundation, Inc. All Rights Reserved. -// -// SPDX-License-Identifier: Apache-2.0 - -package fakes - -import ( - "sync" - - "github.com/paketo-buildpacks/packit/v2/pexec" -) - -type Executable struct { - ExecuteCall struct { - mutex sync.Mutex - CallCount int - Receives struct { - Execution pexec.Execution - } - Returns struct { - Error error - } - Stub func(pexec.Execution) error - } -} - -func (f *Executable) Execute(param1 pexec.Execution) error { - f.ExecuteCall.mutex.Lock() - defer f.ExecuteCall.mutex.Unlock() - f.ExecuteCall.CallCount++ - f.ExecuteCall.Receives.Execution = param1 - if f.ExecuteCall.Stub != nil { - return f.ExecuteCall.Stub(param1) - } - return f.ExecuteCall.Returns.Error -} diff --git a/pkg/installers/poetry/poetry_install_process_test.go b/pkg/installers/poetry/poetry_install_process_test.go index 6328795..035b7df 100644 --- a/pkg/installers/poetry/poetry_install_process_test.go +++ b/pkg/installers/poetry/poetry_install_process_test.go @@ -13,8 +13,8 @@ import ( "github.com/paketo-buildpacks/packit/v2/pexec" "github.com/sclevine/spec" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/executable/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/poetry" - "github.com/paketo-buildpacks/python-installers/pkg/installers/poetry/fakes" . "github.com/onsi/gomega" ) diff --git a/pkg/installers/poetry/site_process_test.go b/pkg/installers/poetry/site_process_test.go index fd11c4d..81ad08e 100644 --- a/pkg/installers/poetry/site_process_test.go +++ b/pkg/installers/poetry/site_process_test.go @@ -14,8 +14,8 @@ import ( "github.com/paketo-buildpacks/packit/v2/pexec" "github.com/sclevine/spec" + "github.com/paketo-buildpacks/python-installers/pkg/installers/common/executable/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/poetry" - "github.com/paketo-buildpacks/python-installers/pkg/installers/poetry/fakes" . "github.com/onsi/gomega" ) From 6f2d44f7c4a7c02e3b5be1288f45d7663644924d Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sat, 21 Feb 2026 08:56:35 +0100 Subject: [PATCH 7/9] refactor: move common content into pkg Since the content is indeed used by all the installers, make it accessible at the pkg level rather that having the indirection of common. --- build.go | 2 +- build_test.go | 6 +++--- detect_test.go | 2 +- pkg/{installers/common => }/build/build.go | 2 +- pkg/{installers/common => }/dependency/dependency.go | 0 .../common => }/dependency/fakes/dependency_manager.go | 0 pkg/{installers/common => }/executable/executable.go | 0 pkg/{installers/common => }/executable/fakes/executable.go | 0 pkg/installers/miniconda/build.go | 4 ++-- pkg/installers/miniconda/build_test.go | 6 +++--- pkg/installers/miniconda/detect.go | 2 +- pkg/installers/miniconda/detect_test.go | 2 +- pkg/installers/miniconda/script_runner_test.go | 2 +- pkg/installers/pip/build.go | 4 ++-- pkg/installers/pip/build_test.go | 6 +++--- pkg/installers/pip/detect.go | 2 +- pkg/installers/pip/detect_test.go | 2 +- pkg/installers/pip/pip_install_process_test.go | 2 +- pkg/installers/pip/site_process_test.go | 2 +- pkg/installers/pipenv/build.go | 4 ++-- pkg/installers/pipenv/build_test.go | 6 +++--- pkg/installers/pipenv/detect.go | 2 +- pkg/installers/pipenv/detect_test.go | 2 +- pkg/installers/pipenv/pipenv_install_process_test.go | 2 +- pkg/installers/pipenv/site_process_test.go | 2 +- pkg/installers/pixi/build.go | 4 ++-- pkg/installers/pixi/build_test.go | 6 +++--- pkg/installers/pixi/detect.go | 2 +- pkg/installers/pixi/detect_test.go | 2 +- pkg/installers/poetry/build.go | 4 ++-- pkg/installers/poetry/build_test.go | 6 +++--- pkg/installers/poetry/detect.go | 2 +- pkg/installers/poetry/detect_test.go | 2 +- pkg/installers/poetry/poetry_install_process_test.go | 2 +- pkg/installers/poetry/site_process_test.go | 2 +- pkg/installers/uv/build.go | 4 ++-- pkg/installers/uv/build_test.go | 6 +++--- pkg/installers/uv/detect.go | 2 +- pkg/installers/uv/detect_test.go | 2 +- pkg/{installers/common => }/sbom/fakes/sbom_generator.go | 0 pkg/{installers/common => }/sbom/sbom.go | 0 run/main.go | 4 ++-- 42 files changed, 57 insertions(+), 57 deletions(-) rename pkg/{installers/common => }/build/build.go (93%) rename pkg/{installers/common => }/dependency/dependency.go (100%) rename pkg/{installers/common => }/dependency/fakes/dependency_manager.go (100%) rename pkg/{installers/common => }/executable/executable.go (100%) rename pkg/{installers/common => }/executable/fakes/executable.go (100%) rename pkg/{installers/common => }/sbom/fakes/sbom_generator.go (100%) rename pkg/{installers/common => }/sbom/sbom.go (100%) diff --git a/build.go b/build.go index c9c7092..ff34322 100644 --- a/build.go +++ b/build.go @@ -18,7 +18,7 @@ import ( poetry "github.com/paketo-buildpacks/python-installers/pkg/installers/poetry" uv "github.com/paketo-buildpacks/python-installers/pkg/installers/uv" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + "github.com/paketo-buildpacks/python-installers/pkg/build" ) type PackagerParameters interface { diff --git a/build_test.go b/build_test.go index 5fc4e67..db94476 100644 --- a/build_test.go +++ b/build_test.go @@ -22,9 +22,8 @@ import ( "github.com/paketo-buildpacks/packit/v2/scribe" pythoninstallers "github.com/paketo-buildpacks/python-installers" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" - dependencyfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency/fakes" - sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" + "github.com/paketo-buildpacks/python-installers/pkg/build" + dependencyfakes "github.com/paketo-buildpacks/python-installers/pkg/dependency/fakes" miniconda "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda" minicondafakes "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda/fakes" pip "github.com/paketo-buildpacks/python-installers/pkg/installers/pip" @@ -37,6 +36,7 @@ import ( poetryfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/poetry/fakes" uv "github.com/paketo-buildpacks/python-installers/pkg/installers/uv" uvfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/uv/fakes" + sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/sbom/fakes" . "github.com/onsi/gomega" "github.com/sclevine/spec" diff --git a/detect_test.go b/detect_test.go index c247273..87f0a06 100644 --- a/detect_test.go +++ b/detect_test.go @@ -15,7 +15,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/scribe" pythoninstallers "github.com/paketo-buildpacks/python-installers" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + "github.com/paketo-buildpacks/python-installers/pkg/build" miniconda "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda" pip "github.com/paketo-buildpacks/python-installers/pkg/installers/pip" diff --git a/pkg/installers/common/build/build.go b/pkg/build/build.go similarity index 93% rename from pkg/installers/common/build/build.go rename to pkg/build/build.go index 7c6a1ca..087a658 100644 --- a/pkg/installers/common/build/build.go +++ b/pkg/build/build.go @@ -9,7 +9,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/chronos" "github.com/paketo-buildpacks/packit/v2/scribe" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom" + "github.com/paketo-buildpacks/python-installers/pkg/sbom" ) // CommonBuildParameters are the parameters shared diff --git a/pkg/installers/common/dependency/dependency.go b/pkg/dependency/dependency.go similarity index 100% rename from pkg/installers/common/dependency/dependency.go rename to pkg/dependency/dependency.go diff --git a/pkg/installers/common/dependency/fakes/dependency_manager.go b/pkg/dependency/fakes/dependency_manager.go similarity index 100% rename from pkg/installers/common/dependency/fakes/dependency_manager.go rename to pkg/dependency/fakes/dependency_manager.go diff --git a/pkg/installers/common/executable/executable.go b/pkg/executable/executable.go similarity index 100% rename from pkg/installers/common/executable/executable.go rename to pkg/executable/executable.go diff --git a/pkg/installers/common/executable/fakes/executable.go b/pkg/executable/fakes/executable.go similarity index 100% rename from pkg/installers/common/executable/fakes/executable.go rename to pkg/executable/fakes/executable.go diff --git a/pkg/installers/miniconda/build.go b/pkg/installers/miniconda/build.go index 5ff28ee..1856e76 100644 --- a/pkg/installers/miniconda/build.go +++ b/pkg/installers/miniconda/build.go @@ -14,8 +14,8 @@ import ( "github.com/paketo-buildpacks/packit/v2/draft" "github.com/paketo-buildpacks/packit/v2/sbom" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency" + "github.com/paketo-buildpacks/python-installers/pkg/build" + "github.com/paketo-buildpacks/python-installers/pkg/dependency" ) //go:generate faux --interface Runner --output fakes/runner.go diff --git a/pkg/installers/miniconda/build_test.go b/pkg/installers/miniconda/build_test.go index 014326f..5c3d1b5 100644 --- a/pkg/installers/miniconda/build_test.go +++ b/pkg/installers/miniconda/build_test.go @@ -14,9 +14,9 @@ import ( "github.com/paketo-buildpacks/packit/v2" "github.com/paketo-buildpacks/packit/v2/chronos" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" - dependencyfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency/fakes" - sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" + "github.com/paketo-buildpacks/python-installers/pkg/build" + dependencyfakes "github.com/paketo-buildpacks/python-installers/pkg/dependency/fakes" + sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/sbom/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda" "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda/fakes" diff --git a/pkg/installers/miniconda/detect.go b/pkg/installers/miniconda/detect.go index 17b33ae..40f85e6 100644 --- a/pkg/installers/miniconda/detect.go +++ b/pkg/installers/miniconda/detect.go @@ -9,7 +9,7 @@ import ( "github.com/paketo-buildpacks/packit/v2" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + "github.com/paketo-buildpacks/python-installers/pkg/build" ) // Detect will return a packit.DetectFunc that will be invoked during the diff --git a/pkg/installers/miniconda/detect_test.go b/pkg/installers/miniconda/detect_test.go index 334d34a..f046d51 100644 --- a/pkg/installers/miniconda/detect_test.go +++ b/pkg/installers/miniconda/detect_test.go @@ -10,7 +10,7 @@ import ( "github.com/paketo-buildpacks/packit/v2" "github.com/sclevine/spec" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + "github.com/paketo-buildpacks/python-installers/pkg/build" "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda" diff --git a/pkg/installers/miniconda/script_runner_test.go b/pkg/installers/miniconda/script_runner_test.go index 476f8a4..bff8918 100644 --- a/pkg/installers/miniconda/script_runner_test.go +++ b/pkg/installers/miniconda/script_runner_test.go @@ -12,7 +12,7 @@ import ( "github.com/sclevine/spec" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/executable/fakes" + "github.com/paketo-buildpacks/python-installers/pkg/executable/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda" . "github.com/onsi/gomega" diff --git a/pkg/installers/pip/build.go b/pkg/installers/pip/build.go index 58107ba..c41be27 100644 --- a/pkg/installers/pip/build.go +++ b/pkg/installers/pip/build.go @@ -15,8 +15,8 @@ import ( "github.com/paketo-buildpacks/packit/v2/draft" "github.com/paketo-buildpacks/packit/v2/sbom" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency" + "github.com/paketo-buildpacks/python-installers/pkg/build" + "github.com/paketo-buildpacks/python-installers/pkg/dependency" ) //go:generate faux --interface InstallProcess --output fakes/install_process.go diff --git a/pkg/installers/pip/build_test.go b/pkg/installers/pip/build_test.go index 69e2dbd..095dd90 100644 --- a/pkg/installers/pip/build_test.go +++ b/pkg/installers/pip/build_test.go @@ -22,9 +22,9 @@ import ( "github.com/paketo-buildpacks/packit/v2/scribe" "github.com/sclevine/spec" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" - dependencyfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency/fakes" - sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" + "github.com/paketo-buildpacks/python-installers/pkg/build" + dependencyfakes "github.com/paketo-buildpacks/python-installers/pkg/dependency/fakes" + sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/sbom/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/pip" "github.com/paketo-buildpacks/python-installers/pkg/installers/pip/fakes" diff --git a/pkg/installers/pip/detect.go b/pkg/installers/pip/detect.go index a636737..b92f7c6 100644 --- a/pkg/installers/pip/detect.go +++ b/pkg/installers/pip/detect.go @@ -10,7 +10,7 @@ import ( "github.com/paketo-buildpacks/packit/v2" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + "github.com/paketo-buildpacks/python-installers/pkg/build" ) // Return a pip requirement diff --git a/pkg/installers/pip/detect_test.go b/pkg/installers/pip/detect_test.go index 2183d46..7fbc2fa 100644 --- a/pkg/installers/pip/detect_test.go +++ b/pkg/installers/pip/detect_test.go @@ -12,7 +12,7 @@ import ( . "github.com/onsi/gomega" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + "github.com/paketo-buildpacks/python-installers/pkg/build" "github.com/paketo-buildpacks/python-installers/pkg/installers/pip" ) diff --git a/pkg/installers/pip/pip_install_process_test.go b/pkg/installers/pip/pip_install_process_test.go index 3b4c11c..ac23ffa 100644 --- a/pkg/installers/pip/pip_install_process_test.go +++ b/pkg/installers/pip/pip_install_process_test.go @@ -13,7 +13,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/pexec" "github.com/sclevine/spec" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/executable/fakes" + "github.com/paketo-buildpacks/python-installers/pkg/executable/fakes" pip "github.com/paketo-buildpacks/python-installers/pkg/installers/pip" . "github.com/onsi/gomega" diff --git a/pkg/installers/pip/site_process_test.go b/pkg/installers/pip/site_process_test.go index 9880f0d..4119fd0 100644 --- a/pkg/installers/pip/site_process_test.go +++ b/pkg/installers/pip/site_process_test.go @@ -14,7 +14,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/pexec" "github.com/sclevine/spec" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/executable/fakes" + "github.com/paketo-buildpacks/python-installers/pkg/executable/fakes" pip "github.com/paketo-buildpacks/python-installers/pkg/installers/pip" . "github.com/onsi/gomega" diff --git a/pkg/installers/pipenv/build.go b/pkg/installers/pipenv/build.go index afd585e..f4e5733 100644 --- a/pkg/installers/pipenv/build.go +++ b/pkg/installers/pipenv/build.go @@ -14,8 +14,8 @@ import ( "github.com/paketo-buildpacks/packit/v2/draft" "github.com/paketo-buildpacks/packit/v2/sbom" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency" + "github.com/paketo-buildpacks/python-installers/pkg/build" + "github.com/paketo-buildpacks/python-installers/pkg/dependency" ) //go:generate faux --interface InstallProcess --output fakes/install_process.go diff --git a/pkg/installers/pipenv/build_test.go b/pkg/installers/pipenv/build_test.go index 00994f4..9c7a00f 100644 --- a/pkg/installers/pipenv/build_test.go +++ b/pkg/installers/pipenv/build_test.go @@ -22,11 +22,11 @@ import ( "github.com/paketo-buildpacks/packit/v2/scribe" "github.com/sclevine/spec" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" - dependencyfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency/fakes" - sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" + "github.com/paketo-buildpacks/python-installers/pkg/build" + dependencyfakes "github.com/paketo-buildpacks/python-installers/pkg/dependency/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/pipenv" "github.com/paketo-buildpacks/python-installers/pkg/installers/pipenv/fakes" + sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/sbom/fakes" . "github.com/onsi/gomega" ) diff --git a/pkg/installers/pipenv/detect.go b/pkg/installers/pipenv/detect.go index be132c9..433d4e3 100644 --- a/pkg/installers/pipenv/detect.go +++ b/pkg/installers/pipenv/detect.go @@ -9,7 +9,7 @@ import ( "github.com/paketo-buildpacks/packit/v2" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + "github.com/paketo-buildpacks/python-installers/pkg/build" "github.com/paketo-buildpacks/python-installers/pkg/installers/pip" ) diff --git a/pkg/installers/pipenv/detect_test.go b/pkg/installers/pipenv/detect_test.go index 0dfc2cc..91e84e1 100644 --- a/pkg/installers/pipenv/detect_test.go +++ b/pkg/installers/pipenv/detect_test.go @@ -13,7 +13,7 @@ import ( "github.com/sclevine/spec" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + "github.com/paketo-buildpacks/python-installers/pkg/build" "github.com/paketo-buildpacks/python-installers/pkg/installers/pipenv" . "github.com/onsi/gomega" diff --git a/pkg/installers/pipenv/pipenv_install_process_test.go b/pkg/installers/pipenv/pipenv_install_process_test.go index 7277353..c78cc64 100644 --- a/pkg/installers/pipenv/pipenv_install_process_test.go +++ b/pkg/installers/pipenv/pipenv_install_process_test.go @@ -14,7 +14,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/pexec" "github.com/sclevine/spec" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/executable/fakes" + "github.com/paketo-buildpacks/python-installers/pkg/executable/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/pipenv" . "github.com/onsi/gomega" diff --git a/pkg/installers/pipenv/site_process_test.go b/pkg/installers/pipenv/site_process_test.go index 905be99..62c380c 100644 --- a/pkg/installers/pipenv/site_process_test.go +++ b/pkg/installers/pipenv/site_process_test.go @@ -14,7 +14,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/pexec" "github.com/sclevine/spec" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/executable/fakes" + "github.com/paketo-buildpacks/python-installers/pkg/executable/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/pipenv" . "github.com/onsi/gomega" diff --git a/pkg/installers/pixi/build.go b/pkg/installers/pixi/build.go index f91cae7..a4b5db1 100644 --- a/pkg/installers/pixi/build.go +++ b/pkg/installers/pixi/build.go @@ -14,8 +14,8 @@ import ( "github.com/paketo-buildpacks/packit/v2/draft" "github.com/paketo-buildpacks/packit/v2/sbom" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency" + "github.com/paketo-buildpacks/python-installers/pkg/build" + "github.com/paketo-buildpacks/python-installers/pkg/dependency" ) //go:generate faux --interface Runner --output fakes/runner.go diff --git a/pkg/installers/pixi/build_test.go b/pkg/installers/pixi/build_test.go index dd17f90..568c6ca 100644 --- a/pkg/installers/pixi/build_test.go +++ b/pkg/installers/pixi/build_test.go @@ -15,9 +15,9 @@ import ( "github.com/paketo-buildpacks/packit/v2" "github.com/paketo-buildpacks/packit/v2/chronos" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" - dependencyfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency/fakes" - sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" + "github.com/paketo-buildpacks/python-installers/pkg/build" + dependencyfakes "github.com/paketo-buildpacks/python-installers/pkg/dependency/fakes" + sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/sbom/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/pixi" "github.com/paketo-buildpacks/python-installers/pkg/installers/pixi/fakes" diff --git a/pkg/installers/pixi/detect.go b/pkg/installers/pixi/detect.go index 9c55d14..46cdaf3 100644 --- a/pkg/installers/pixi/detect.go +++ b/pkg/installers/pixi/detect.go @@ -12,7 +12,7 @@ import ( "github.com/paketo-buildpacks/packit/v2" "github.com/paketo-buildpacks/packit/v2/fs" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + "github.com/paketo-buildpacks/python-installers/pkg/build" ) // Detect will return a packit.DetectFunc that will be invoked during the diff --git a/pkg/installers/pixi/detect_test.go b/pkg/installers/pixi/detect_test.go index 40ea962..ffcb594 100644 --- a/pkg/installers/pixi/detect_test.go +++ b/pkg/installers/pixi/detect_test.go @@ -13,7 +13,7 @@ import ( "github.com/paketo-buildpacks/packit/v2" "github.com/sclevine/spec" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + "github.com/paketo-buildpacks/python-installers/pkg/build" "github.com/paketo-buildpacks/python-installers/pkg/installers/pixi" . "github.com/onsi/gomega" diff --git a/pkg/installers/poetry/build.go b/pkg/installers/poetry/build.go index bb8ba67..127ec3b 100644 --- a/pkg/installers/poetry/build.go +++ b/pkg/installers/poetry/build.go @@ -14,8 +14,8 @@ import ( "github.com/paketo-buildpacks/packit/v2/draft" "github.com/paketo-buildpacks/packit/v2/sbom" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency" + "github.com/paketo-buildpacks/python-installers/pkg/build" + "github.com/paketo-buildpacks/python-installers/pkg/dependency" ) //go:generate faux --interface InstallProcess --output fakes/install_process.go diff --git a/pkg/installers/poetry/build_test.go b/pkg/installers/poetry/build_test.go index fe13feb..26bcb84 100644 --- a/pkg/installers/poetry/build_test.go +++ b/pkg/installers/poetry/build_test.go @@ -21,9 +21,9 @@ import ( "github.com/paketo-buildpacks/packit/v2/scribe" "github.com/sclevine/spec" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" - dependencyfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency/fakes" - sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" + "github.com/paketo-buildpacks/python-installers/pkg/build" + dependencyfakes "github.com/paketo-buildpacks/python-installers/pkg/dependency/fakes" + sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/sbom/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/poetry" "github.com/paketo-buildpacks/python-installers/pkg/installers/poetry/fakes" diff --git a/pkg/installers/poetry/detect.go b/pkg/installers/poetry/detect.go index 5f7d480..20320e8 100644 --- a/pkg/installers/poetry/detect.go +++ b/pkg/installers/poetry/detect.go @@ -8,7 +8,7 @@ import ( "os" "path/filepath" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + "github.com/paketo-buildpacks/python-installers/pkg/build" "github.com/paketo-buildpacks/python-installers/pkg/installers/pip" "github.com/paketo-buildpacks/packit/v2" diff --git a/pkg/installers/poetry/detect_test.go b/pkg/installers/poetry/detect_test.go index a8a5446..7c59376 100644 --- a/pkg/installers/poetry/detect_test.go +++ b/pkg/installers/poetry/detect_test.go @@ -17,7 +17,7 @@ import ( "github.com/paketo-buildpacks/python-installers/pkg/installers/poetry" "github.com/paketo-buildpacks/python-installers/pkg/installers/poetry/fakes" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + "github.com/paketo-buildpacks/python-installers/pkg/build" ) func testDetect(t *testing.T, context spec.G, it spec.S) { diff --git a/pkg/installers/poetry/poetry_install_process_test.go b/pkg/installers/poetry/poetry_install_process_test.go index 035b7df..3c4baf6 100644 --- a/pkg/installers/poetry/poetry_install_process_test.go +++ b/pkg/installers/poetry/poetry_install_process_test.go @@ -13,7 +13,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/pexec" "github.com/sclevine/spec" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/executable/fakes" + "github.com/paketo-buildpacks/python-installers/pkg/executable/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/poetry" . "github.com/onsi/gomega" diff --git a/pkg/installers/poetry/site_process_test.go b/pkg/installers/poetry/site_process_test.go index 81ad08e..9718c9e 100644 --- a/pkg/installers/poetry/site_process_test.go +++ b/pkg/installers/poetry/site_process_test.go @@ -14,7 +14,7 @@ import ( "github.com/paketo-buildpacks/packit/v2/pexec" "github.com/sclevine/spec" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/executable/fakes" + "github.com/paketo-buildpacks/python-installers/pkg/executable/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/poetry" . "github.com/onsi/gomega" diff --git a/pkg/installers/uv/build.go b/pkg/installers/uv/build.go index 6a34114..a8d55b2 100644 --- a/pkg/installers/uv/build.go +++ b/pkg/installers/uv/build.go @@ -14,8 +14,8 @@ import ( "github.com/paketo-buildpacks/packit/v2/draft" "github.com/paketo-buildpacks/packit/v2/sbom" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency" + "github.com/paketo-buildpacks/python-installers/pkg/build" + "github.com/paketo-buildpacks/python-installers/pkg/dependency" ) //go:generate faux --interface Runner --output fakes/runner.go diff --git a/pkg/installers/uv/build_test.go b/pkg/installers/uv/build_test.go index e0919a4..d545639 100644 --- a/pkg/installers/uv/build_test.go +++ b/pkg/installers/uv/build_test.go @@ -15,9 +15,9 @@ import ( "github.com/paketo-buildpacks/packit/v2" "github.com/paketo-buildpacks/packit/v2/chronos" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" - dependencyfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/dependency/fakes" - sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom/fakes" + "github.com/paketo-buildpacks/python-installers/pkg/build" + dependencyfakes "github.com/paketo-buildpacks/python-installers/pkg/dependency/fakes" + sbomfakes "github.com/paketo-buildpacks/python-installers/pkg/sbom/fakes" "github.com/paketo-buildpacks/python-installers/pkg/installers/uv" "github.com/paketo-buildpacks/python-installers/pkg/installers/uv/fakes" diff --git a/pkg/installers/uv/detect.go b/pkg/installers/uv/detect.go index c2efbc3..c64e5ff 100644 --- a/pkg/installers/uv/detect.go +++ b/pkg/installers/uv/detect.go @@ -12,7 +12,7 @@ import ( "github.com/paketo-buildpacks/packit/v2" "github.com/paketo-buildpacks/packit/v2/fs" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + "github.com/paketo-buildpacks/python-installers/pkg/build" ) // Detect will return a packit.DetectFunc that will be invoked during the diff --git a/pkg/installers/uv/detect_test.go b/pkg/installers/uv/detect_test.go index 69e3c50..e62d21c 100644 --- a/pkg/installers/uv/detect_test.go +++ b/pkg/installers/uv/detect_test.go @@ -13,7 +13,7 @@ import ( "github.com/paketo-buildpacks/packit/v2" "github.com/sclevine/spec" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" + "github.com/paketo-buildpacks/python-installers/pkg/build" "github.com/paketo-buildpacks/python-installers/pkg/installers/uv" . "github.com/onsi/gomega" diff --git a/pkg/installers/common/sbom/fakes/sbom_generator.go b/pkg/sbom/fakes/sbom_generator.go similarity index 100% rename from pkg/installers/common/sbom/fakes/sbom_generator.go rename to pkg/sbom/fakes/sbom_generator.go diff --git a/pkg/installers/common/sbom/sbom.go b/pkg/sbom/sbom.go similarity index 100% rename from pkg/installers/common/sbom/sbom.go rename to pkg/sbom/sbom.go diff --git a/run/main.go b/run/main.go index c343659..b6ece58 100644 --- a/run/main.go +++ b/run/main.go @@ -16,14 +16,14 @@ import ( "github.com/paketo-buildpacks/packit/v2/scribe" pythoninstallers "github.com/paketo-buildpacks/python-installers" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/build" - "github.com/paketo-buildpacks/python-installers/pkg/installers/common/sbom" + "github.com/paketo-buildpacks/python-installers/pkg/build" miniconda "github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda" pip "github.com/paketo-buildpacks/python-installers/pkg/installers/pip" pipenv "github.com/paketo-buildpacks/python-installers/pkg/installers/pipenv" pixi "github.com/paketo-buildpacks/python-installers/pkg/installers/pixi" poetry "github.com/paketo-buildpacks/python-installers/pkg/installers/poetry" uv "github.com/paketo-buildpacks/python-installers/pkg/installers/uv" + "github.com/paketo-buildpacks/python-installers/pkg/sbom" ) func main() { From 06fba4c889cc696f5f81f2ea9025a4fd4c9b4f39 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sat, 21 Feb 2026 14:40:09 +0100 Subject: [PATCH 8/9] chore: remove stray print in tests --- integration/installers/miniconda_default_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/integration/installers/miniconda_default_test.go b/integration/installers/miniconda_default_test.go index 44f266c..842fbd0 100644 --- a/integration/installers/miniconda_default_test.go +++ b/integration/installers/miniconda_default_test.go @@ -64,7 +64,6 @@ func minicondaTestDefault(t *testing.T, context spec.G, it spec.S) { err error ) - fmt.Printf("Settings are: %s", settings) image, logs, err = pack.WithNoColor().Build. WithPullPolicy("never"). WithBuildpacks( From 4868502b3f14773656b62335dabe0f1ec7aa87d5 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sat, 21 Feb 2026 15:51:19 +0100 Subject: [PATCH 9/9] refactor: cleanup Executable Use the new dedicated module --- pkg/installers/miniconda/script_runner.go | 13 ++++--------- pkg/installers/pip/pip_install_process.go | 13 ++++--------- pkg/installers/pip/site_process.go | 6 ++++-- pkg/installers/pipenv/pipenv_install_process.go | 13 ++++--------- pkg/installers/pipenv/site_process.go | 6 ++++-- pkg/installers/poetry/poetry_install_process.go | 13 ++++--------- pkg/installers/poetry/site_process.go | 6 ++++-- 7 files changed, 28 insertions(+), 42 deletions(-) diff --git a/pkg/installers/miniconda/script_runner.go b/pkg/installers/miniconda/script_runner.go index 9126322..3fd1268 100644 --- a/pkg/installers/miniconda/script_runner.go +++ b/pkg/installers/miniconda/script_runner.go @@ -9,22 +9,17 @@ import ( "fmt" "github.com/paketo-buildpacks/packit/v2/pexec" -) - -//go:generate faux --interface Executable --output fakes/executable.go -// Executable defines the interface for invoking an executable. -type Executable interface { - Execute(execution pexec.Execution) error -} + "github.com/paketo-buildpacks/python-installers/pkg/executable" +) // ScriptRunner implements the Runner interface type ScriptRunner struct { - executable Executable + executable executable.Executable } // NewScriptRunner creates an instance of the ScriptRunner given an Executable that runs `bash`. -func NewScriptRunner(executable Executable) ScriptRunner { +func NewScriptRunner(executable executable.Executable) ScriptRunner { return ScriptRunner{ executable: executable, } diff --git a/pkg/installers/pip/pip_install_process.go b/pkg/installers/pip/pip_install_process.go index 006b77e..00c319d 100644 --- a/pkg/installers/pip/pip_install_process.go +++ b/pkg/installers/pip/pip_install_process.go @@ -10,22 +10,17 @@ import ( "os" "github.com/paketo-buildpacks/packit/v2/pexec" -) - -//go:generate faux --interface Executable --output fakes/executable.go -// Executable defines the interface for invoking an executable. -type Executable interface { - Execute(pexec.Execution) error -} + "github.com/paketo-buildpacks/python-installers/pkg/executable" +) // PipInstallProcess implements the InstallProcess interface. type PipInstallProcess struct { - executable Executable + executable executable.Executable } // NewPipInstallProcess creates an instance of the PipInstallProcess given an Executable that runs `python`. -func NewPipInstallProcess(executable Executable) PipInstallProcess { +func NewPipInstallProcess(executable executable.Executable) PipInstallProcess { return PipInstallProcess{ executable: executable, } diff --git a/pkg/installers/pip/site_process.go b/pkg/installers/pip/site_process.go index 41e2961..e62ed5c 100644 --- a/pkg/installers/pip/site_process.go +++ b/pkg/installers/pip/site_process.go @@ -10,15 +10,17 @@ import ( "os" "github.com/paketo-buildpacks/packit/v2/pexec" + + "github.com/paketo-buildpacks/python-installers/pkg/executable" ) // SiteProcess implements the Executable interface. type SiteProcess struct { - executable Executable + executable executable.Executable } // NewSiteProcess creates an instance of the SiteProcess given an Executable that runs `python` -func NewSiteProcess(executable Executable) SiteProcess { +func NewSiteProcess(executable executable.Executable) SiteProcess { return SiteProcess{ executable: executable, } diff --git a/pkg/installers/pipenv/pipenv_install_process.go b/pkg/installers/pipenv/pipenv_install_process.go index eb0af56..a7a4f0b 100644 --- a/pkg/installers/pipenv/pipenv_install_process.go +++ b/pkg/installers/pipenv/pipenv_install_process.go @@ -11,21 +11,16 @@ import ( "path/filepath" "github.com/paketo-buildpacks/packit/v2/pexec" -) - -//go:generate faux --interface Executable --output fakes/executable.go -// Executable defines the interface for invoking an executable. -type Executable interface { - Execute(pexec.Execution) error -} + "github.com/paketo-buildpacks/python-installers/pkg/executable" +) type PipenvInstallProcess struct { - executable Executable + executable executable.Executable } // NewPipenvInstallProcess creates a PipenvInstallProcess instance. -func NewPipenvInstallProcess(executable Executable) PipenvInstallProcess { +func NewPipenvInstallProcess(executable executable.Executable) PipenvInstallProcess { return PipenvInstallProcess{ executable: executable, } diff --git a/pkg/installers/pipenv/site_process.go b/pkg/installers/pipenv/site_process.go index cde3027..faf9d4c 100644 --- a/pkg/installers/pipenv/site_process.go +++ b/pkg/installers/pipenv/site_process.go @@ -10,15 +10,17 @@ import ( "os" "github.com/paketo-buildpacks/packit/v2/pexec" + + "github.com/paketo-buildpacks/python-installers/pkg/executable" ) // SiteProcess implements the Executable interface. type SiteProcess struct { - executable Executable + executable executable.Executable } // NewSiteProcess creates an instance of the SiteProcess given an Executable. -func NewSiteProcess(executable Executable) SiteProcess { +func NewSiteProcess(executable executable.Executable) SiteProcess { return SiteProcess{ executable: executable, } diff --git a/pkg/installers/poetry/poetry_install_process.go b/pkg/installers/poetry/poetry_install_process.go index 3e4fbbb..c9b9a55 100644 --- a/pkg/installers/poetry/poetry_install_process.go +++ b/pkg/installers/poetry/poetry_install_process.go @@ -11,21 +11,16 @@ import ( "path/filepath" "github.com/paketo-buildpacks/packit/v2/pexec" -) - -//go:generate faux --interface Executable --output fakes/executable.go -// Executable defines the interface for invoking an executable. -type Executable interface { - Execute(pexec.Execution) error -} + "github.com/paketo-buildpacks/python-installers/pkg/executable" +) type PoetryInstallProcess struct { - executable Executable + executable executable.Executable } // NewPoetryInstallProcess creates a PoetryInstallProcess instance. -func NewPoetryInstallProcess(executable Executable) PoetryInstallProcess { +func NewPoetryInstallProcess(executable executable.Executable) PoetryInstallProcess { return PoetryInstallProcess{ executable: executable, } diff --git a/pkg/installers/poetry/site_process.go b/pkg/installers/poetry/site_process.go index c47c0fe..cc394e8 100644 --- a/pkg/installers/poetry/site_process.go +++ b/pkg/installers/poetry/site_process.go @@ -10,15 +10,17 @@ import ( "os" "github.com/paketo-buildpacks/packit/v2/pexec" + + "github.com/paketo-buildpacks/python-installers/pkg/executable" ) // SiteProcess implements the Executable interface. type SiteProcess struct { - executable Executable + executable executable.Executable } // NewSiteProcess creates an instance of the SiteProcess given an Executable. -func NewSiteProcess(executable Executable) SiteProcess { +func NewSiteProcess(executable executable.Executable) SiteProcess { return SiteProcess{ executable: executable, }