Skip to content

Commit

Permalink
Adds logging to detection
Browse files Browse the repository at this point in the history
  • Loading branch information
pivotal-david-osullivan committed May 22, 2023
1 parent 6b8d3d4 commit 3a3f027
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(
yourkit.Detect{},
yourkit.Build{Logger: bard.NewLogger(os.Stdout)},
yourkit.Detect{Logger: logger},
yourkit.Build{Logger: logger},
)
}
8 changes: 6 additions & 2 deletions yourkit/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,21 @@ import (

"github.com/buildpacks/libcnb"
"github.com/paketo-buildpacks/libpak"
"github.com/paketo-buildpacks/libpak/bard"
)

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)
}

if _, ok := cr.Resolve("BP_YOURKIT_ENABLED"); !ok {
d.Logger.Info("SKIPPED: variable 'BP_YOURKIT_ENABLED' not set to true")
return libcnb.DetectResult{Pass: false}, nil
}

Expand Down

0 comments on commit 3a3f027

Please sign in to comment.