diff --git a/build.go b/build.go index ed1b257..4543b76 100644 --- a/build.go +++ b/build.go @@ -107,7 +107,7 @@ func Build( logger.Action("Completed in %s", duration.Round(time.Millisecond)) logger.Break() - logger.Process("Generating SBOM for directory %s", yarnLayer.Path) + logger.GeneratingSBOM(yarnLayer.Path) var sbomContent sbom.SBOM duration, err = clock.Measure(func() error { sbomContent, err = sbomGenerator.GenerateFromDependency(dependency, context.WorkingDir) @@ -120,6 +120,7 @@ func Build( logger.Action("Completed in %s", duration.Round(time.Millisecond)) logger.Break() + logger.FormattingSBOM(context.BuildpackInfo.SBOMFormats...) yarnLayer.SBOM, err = sbomContent.InFormats(context.BuildpackInfo.SBOMFormats...) if err != nil { return packit.BuildResult{}, err diff --git a/integration/default_test.go b/integration/default_test.go index 64971c1..97126a0 100644 --- a/integration/default_test.go +++ b/integration/default_test.go @@ -71,6 +71,7 @@ func testDefault(t *testing.T, context spec.G, it spec.S) { WithPullPolicy("never"). WithBuildpacks(buildpack, buildPlanBuildpack). WithSBOMOutputDir(sbomDir). + WithEnv(map[string]string{"BP_LOG_LEVEL": "DEBUG"}). Execute(name, source) Expect(err).ToNot(HaveOccurred(), logs.String) @@ -90,6 +91,15 @@ func testDefault(t *testing.T, context spec.G, it spec.S) { " Executing build process", MatchRegexp(` Installing Yarn`), MatchRegexp(` Completed in ([0-9]*(\.[0-9]*)?[a-z]+)+`), + "", + fmt.Sprintf(" Generating SBOM for directory /layers/%s/yarn", strings.ReplaceAll(buildpackInfo.Buildpack.ID, "/", "_")), + MatchRegexp(` Completed in \d+(\.?\d+)*`), + "", + " Writing SBOM in the following format(s):", + " application/vnd.cyclonedx+json", + " application/spdx+json", + " application/vnd.syft+json", + "", )) // check that all required SBOM files are present diff --git a/run/main.go b/run/main.go index 3b39142..ea344fd 100644 --- a/run/main.go +++ b/run/main.go @@ -22,7 +22,7 @@ func (f Generator) GenerateFromDependency(dependency postal.Dependency, path str func main() { entryResolver := draft.NewPlanner() dependencyManager := postal.NewService(cargo.NewTransport()) - logEmitter := scribe.NewEmitter(os.Stdout) + logEmitter := scribe.NewEmitter(os.Stdout).WithLevel(os.Getenv("BP_LOG_LEVEL")) packit.Run( yarn.Detect(),