Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
- pack download-sbom -> pack sbom download ....
- Add warning message for pack inspect-image <> --bom

Signed-off-by: Anthony Emengo <aemengo@vmware.com>
  • Loading branch information
Anthony Emengo committed Jan 10, 2022
1 parent 4cf55bb commit f027b65
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func NewPackCommand(logger ConfigurableLogger) (*cobra.Command, error) {
rootCmd.AddCommand(commands.InspectImage(logger, imagewriter.NewFactory(), cfg, packClient))
rootCmd.AddCommand(commands.NewStackCommand(logger))
rootCmd.AddCommand(commands.Rebase(logger, cfg, packClient))
rootCmd.AddCommand(commands.DownloadSBOM(logger, packClient))
rootCmd.AddCommand(commands.NewSBOMCommand(logger, cfg, packClient))

rootCmd.AddCommand(commands.InspectBuildpack(logger, cfg, packClient))
rootCmd.AddCommand(commands.InspectBuilder(logger, cfg, packClient, builderwriter.NewFactory()))
Expand Down
6 changes: 3 additions & 3 deletions internal/commands/download_sbom.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ func DownloadSBOM(
) *cobra.Command {
var flags DownloadSBOMFlags
cmd := &cobra.Command{
Use: "download-sbom <image-name>",
Use: "download <image-name>",
Args: cobra.ExactArgs(1),
Short: "Download SBoM from specified image",
Long: "Download layer containing Structured Bill of Materials (SBoM) from specified image",
Example: "pack download-sbom buildpacksio/pack",
Example: "pack sbom download buildpacksio/pack",
RunE: logError(logger, func(cmd *cobra.Command, args []string) error {
if flags.Local && flags.Remote {
return errors.New("expected either '--local' or '--remote', not both")
Expand All @@ -39,7 +39,7 @@ func DownloadSBOM(
return client.DownloadSBOM(img, options)
}),
}
AddHelpFlag(cmd, "download-sbom")
AddHelpFlag(cmd, "download")
cmd.Flags().BoolVar(&flags.Local, "local", false, "Pull SBoM from local daemon (Default)")
cmd.Flags().BoolVar(&flags.Remote, "remote", false, "Pull SBoM from remote registry")
cmd.Flags().StringVar(&flags.DestinationDir, "output-dir", ".", "Path to export SBoM contents.\nIt defaults export to the current working directory.")
Expand Down
4 changes: 4 additions & 0 deletions internal/commands/inspect_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ func InspectImage(
remote, remoteErr := client.InspectImage(img, false)
local, localErr := client.InspectImage(img, true)

if flags.BOM {
logger.Warn("Using the '--bom' flag with 'pack inspect-image <image-name>' is deprecated. Users are encouraged to use 'pack sbom download <image-name>'.")
}

if err := w.Print(logger, sharedImageInfo, local, remote, localErr, remoteErr); err != nil {
return err
}
Expand Down
20 changes: 20 additions & 0 deletions internal/commands/sbom.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package commands

import (
"github.com/spf13/cobra"

"github.com/buildpacks/pack/internal/config"
"github.com/buildpacks/pack/pkg/logging"
)

func NewSBOMCommand(logger logging.Logger, cfg config.Config, client PackClient) *cobra.Command {
cmd := &cobra.Command{
Use: "sbom",
Short: "Interact with SBoM",
RunE: nil,
}

cmd.AddCommand(DownloadSBOM(logger, client))
AddHelpFlag(cmd, "sbom")
return cmd
}

0 comments on commit f027b65

Please sign in to comment.