diff --git a/cmd/cmd.go b/cmd/cmd.go index 9945dcf367..9cf792c4bd 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -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())) diff --git a/internal/commands/download_sbom.go b/internal/commands/download_sbom.go index a10990bc24..c74f1ec37f 100644 --- a/internal/commands/download_sbom.go +++ b/internal/commands/download_sbom.go @@ -20,11 +20,11 @@ func DownloadSBOM( ) *cobra.Command { var flags DownloadSBOMFlags cmd := &cobra.Command{ - Use: "download-sbom ", + Use: "download ", 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") @@ -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.") diff --git a/internal/commands/inspect_image.go b/internal/commands/inspect_image.go index 45bc7b394f..ac33f6772c 100644 --- a/internal/commands/inspect_image.go +++ b/internal/commands/inspect_image.go @@ -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 ' is deprecated. Users are encouraged to use 'pack sbom download '.") + } + if err := w.Print(logger, sharedImageInfo, local, remote, localErr, remoteErr); err != nil { return err } diff --git a/internal/commands/sbom.go b/internal/commands/sbom.go new file mode 100644 index 0000000000..39e7c0d015 --- /dev/null +++ b/internal/commands/sbom.go @@ -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 +}