github.com/buildpacks/pack@v0.33.3-0.20240516162812-884dd1837311/internal/commands/manifest_rm.go (about)

     1  package commands
     2  
     3  import (
     4  	"github.com/spf13/cobra"
     5  
     6  	"github.com/buildpacks/pack/pkg/logging"
     7  )
     8  
     9  // ManifestRemove will remove the specified image manifest if it is already referenced in the index
    10  func ManifestRemove(logger logging.Logger, pack PackClient) *cobra.Command {
    11  	cmd := &cobra.Command{
    12  		Use:     "rm [manifest-list] [manifest] [manifest...] [flags]",
    13  		Args:    cobra.MatchAll(cobra.MinimumNArgs(2), cobra.OnlyValidArgs),
    14  		Short:   "Remove an image manifest from a manifest list.",
    15  		Example: `pack manifest rm my-image-index my-image@sha256:<some-sha>`,
    16  		Long: `'manifest rm' will remove the specified image manifest if it is already referenced in the index.
    17  Users must pass the digest of the image in order to delete it from the index.
    18  To discard __all__ the images in an index and the index itself, use 'manifest delete'.`,
    19  		RunE: logError(logger, func(cmd *cobra.Command, args []string) error {
    20  			if err := pack.RemoveManifest(args[0], args[1:]); err != nil {
    21  				return err
    22  			}
    23  			return nil
    24  		}),
    25  	}
    26  
    27  	AddHelpFlag(cmd, "rm")
    28  	return cmd
    29  }