Skip to content

Commit

Permalink
Merge pull request #210 from paketo-buildpacks/detect-logging
Browse files Browse the repository at this point in the history
Adds detection logging messages at info level
  • Loading branch information
anthonydahanne authored May 18, 2023
2 parents 2b0ec8b + 157721f commit 86f07ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions cmd/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ import (
)

func main() {
logger := bard.NewLogger(os.Stdout)
libpak.Main(
executable.Detect{},
executable.Build{Logger: bard.NewLogger(os.Stdout)},
executable.Detect{Logger: logger},
executable.Build{Logger: logger},
)
}
8 changes: 6 additions & 2 deletions executable/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/buildpacks/libcnb"
"github.com/paketo-buildpacks/libjvm"
"github.com/paketo-buildpacks/libpak"
"github.com/paketo-buildpacks/libpak/bard"
)

const (
Expand All @@ -32,10 +33,12 @@ const (
PlanEntrySyft = "syft"
)

type Detect struct{}
type Detect struct{
Logger bard.Logger
}

func (d Detect) Detect(context libcnb.DetectContext) (libcnb.DetectResult, error) {
cr, err := libpak.NewConfigurationResolver(context.Buildpack, nil)
cr, err := libpak.NewConfigurationResolver(context.Buildpack, &d.Logger)
if err != nil {
return libcnb.DetectResult{}, fmt.Errorf("unable to create configuration resolver\n%w", err)
}
Expand Down Expand Up @@ -63,6 +66,7 @@ func (d Detect) Detect(context libcnb.DetectContext) (libcnb.DetectResult, error
}

if _, ok := m.Get("Main-Class"); ok {
d.Logger.Info("PASSED: 'Main-Class' manifest attribute found")
result.Plans[0].Provides = append(result.Plans[0].Provides, libcnb.BuildPlanProvide{Name: PlanEntryJVMApplicationPackage})
}

Expand Down

0 comments on commit 86f07ce

Please sign in to comment.