From 3a3f02712d447916738a35f4fdaeb9b68f6dd0bf Mon Sep 17 00:00:00 2001 From: David O'Sullivan Date: Mon, 22 May 2023 15:01:06 +0100 Subject: [PATCH] Adds logging to detection --- cmd/main/main.go | 5 +++-- yourkit/detect.go | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/main/main.go b/cmd/main/main.go index 36d29f1..a60ac85 100644 --- a/cmd/main/main.go +++ b/cmd/main/main.go @@ -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}, ) } diff --git a/yourkit/detect.go b/yourkit/detect.go index c7a3d29..8fabf2c 100644 --- a/yourkit/detect.go +++ b/yourkit/detect.go @@ -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 }