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

Adds logging to detection #66

Merged
merged 2 commits into from
May 22, 2023
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
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