Skip to content

Commit

Permalink
Merge pull request #169 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 84410b0 + bb73dcf commit bf07c13
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 7 additions & 3 deletions clojure/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ import (
"fmt"
"os"
"path/filepath"

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

const (
Expand All @@ -31,13 +32,16 @@ const (
PlanEntrySyft = "syft"
)

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

func (Detect) Detect(context libcnb.DetectContext) (libcnb.DetectResult, error) {
func (d Detect) Detect(context libcnb.DetectContext) (libcnb.DetectResult, error) {
file := filepath.Join(context.Application.Path, "deps.edn")

_, err := os.Stat(file)
if os.IsNotExist(err) {
d.Logger.Info("SKIPPED: no 'deps.edn' file found in the application path")
return libcnb.DetectResult{Pass: false}, nil
} else if err != nil {
return libcnb.DetectResult{}, fmt.Errorf("unable to determine if %s exists\n%w", file, err)
Expand Down
5 changes: 3 additions & 2 deletions cmd/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ import (
)

func main() {
logger := bard.NewLogger(os.Stdout)
libpak.Main(
clojure.Detect{},
clojure.Detect{Logger: logger},
clojure.Build{
Logger: bard.NewLogger(os.Stdout),
Logger: logger,
ApplicationFactory: libbs.NewApplicationFactory(),
},
)
Expand Down

0 comments on commit bf07c13

Please sign in to comment.