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

Write analyzed.toml with target metadata #22

Merged
merged 1 commit into from
Jun 26, 2024
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
24 changes: 23 additions & 1 deletion cmd/builder/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"encoding/json"
"os"
"path/filepath"
"runtime"

"code.cloudfoundry.org/cnbapplifecycle/pkg/archive"
"code.cloudfoundry.org/cnbapplifecycle/pkg/errors"
Expand Down Expand Up @@ -101,6 +102,13 @@ var builderCmd = &cobra.Command{
return errors.ErrGenericBuild
}

analyzePath := filepath.Join(layersDir, "analyzed.toml")
analyzeMD, err := writeAnalyzed(analyzePath, logger)
if err != nil {
logger.Errorf("failed to create 'analyzed.toml', error: %s\n", err.Error())
return errors.ErrGenericBuild
}

creds, err := keychain.FromEnv()
if err != nil {
logger.Errorf("failed to parse %s environment variable, error: %s\n", keychain.CnbCredentialsEnv, err.Error())
Expand Down Expand Up @@ -128,6 +136,7 @@ var builderCmd = &cobra.Command{
)

detector, err := detectorFactory.NewDetector(platform.LifecycleInputs{
AnalyzedPath: analyzePath,
PlatformAPI: platformAPI,
AppDir: workspaceDir,
BuildpacksDir: buildpacksDir,
Expand Down Expand Up @@ -179,7 +188,7 @@ var builderCmd = &cobra.Command{
Err: os.Stderr,
Plan: plan,
PlatformAPI: platformAPI,
AnalyzeMD: files.Analyzed{},
AnalyzeMD: analyzeMD,
}

logger.Phase("BUILDING")
Expand Down Expand Up @@ -270,3 +279,16 @@ var builderCmd = &cobra.Command{
return nil
},
}

func writeAnalyzed(path string, logger *log.Logger) (files.Analyzed, error) {
analyzed := files.Analyzed{
RunImage: &files.RunImage{
TargetMetadata: &files.TargetMetadata{
OS: "linux",
Arch: runtime.GOARCH,
pbusko marked this conversation as resolved.
Show resolved Hide resolved
},
},
}

return analyzed, files.Handler.WriteAnalyzed(path, &analyzed, logger)
}
2 changes: 2 additions & 0 deletions integration/lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ var _ = Describe("Lifecycle", func() {
Expect(err).To(BeNil())

outString := buf.String()
Expect(outString).To(ContainSubstring("Run image info in analyzed metadata is"))
Expect(outString).To(ContainSubstring("Checking for match against descriptor"))
Expect(outString).To(ContainSubstring("Finished running build"))
Expect(outString).To(ContainSubstring("Copying SBOM files"))
Expect(outString).To(ContainSubstring("Listing processes"))
Expand Down