Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrades to packit v2 #364

Merged
merged 2 commits into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 10 additions & 18 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"time"

"github.com/Masterminds/semver"
"github.com/paketo-buildpacks/packit"
"github.com/paketo-buildpacks/packit/chronos"
"github.com/paketo-buildpacks/packit/fs"
"github.com/paketo-buildpacks/packit/postal"
"github.com/paketo-buildpacks/packit/scribe"
"github.com/paketo-buildpacks/packit/v2"
"github.com/paketo-buildpacks/packit/v2/chronos"
"github.com/paketo-buildpacks/packit/v2/fs"
"github.com/paketo-buildpacks/packit/v2/postal"
"github.com/paketo-buildpacks/packit/v2/scribe"
)

//go:generate faux --interface EntryResolver --output fakes/entry_resolver.go
Expand All @@ -23,7 +23,7 @@ type EntryResolver interface {
//go:generate faux --interface DependencyService --output fakes/dependency_service.go
type DependencyService interface {
Resolve(path, name, version, stack string) (postal.Dependency, error)
Install(dependency postal.Dependency, cnbPath, layerPath string) error
Deliver(dependency postal.Dependency, cnbPath, layerPath, platformPath string) error
GenerateBillOfMaterials(dependencies ...postal.Dependency) []packit.BOMEntry
}

Expand Down Expand Up @@ -141,6 +141,9 @@ func Build(entryResolver EntryResolver, dependencyService DependencyService, cal
}

if !shouldInstall(layer.Metadata, currConfigureBinSHA256, dependency.SHA256) {
logger.Process("Reusing cached layer %s", layer.Path)
logger.Break()

layer.Launch, layer.Build = launch, build

return packit.BuildResult{
Expand All @@ -159,19 +162,9 @@ func Build(entryResolver EntryResolver, dependencyService DependencyService, cal

layer.Launch, layer.Build = launch, build

err = os.MkdirAll(filepath.Join(layer.Path, "bin"), os.ModePerm)
if err != nil {
return packit.BuildResult{}, err
}

err = fs.Copy(configureBinPath, filepath.Join(layer.Path, "bin", "configure"))
if err != nil {
return packit.BuildResult{}, err
}

logger.Subprocess("Installing Nginx Server %s", dependency.Version)
duration, err := clock.Measure(func() error {
return dependencyService.Install(dependency, context.CNBPath, layer.Path)
return dependencyService.Deliver(dependency, context.CNBPath, layer.Path, context.Platform.Path)
})
if err != nil {
return packit.BuildResult{}, err
Expand All @@ -197,7 +190,6 @@ func Build(entryResolver EntryResolver, dependencyService DependencyService, cal
layer.Metadata = map[string]interface{}{
DepKey: dependency.SHA256,
ConfigureBinKey: currConfigureBinSHA256,
"built_at": clock.Now().Format(time.RFC3339Nano),
}

logger.LaunchProcesses(launchMetadata.Processes)
Expand Down
Loading