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

     1  package commands
     2  
     3  import (
     4  	"github.com/spf13/cobra"
     5  
     6  	"github.com/buildpacks/pack/pkg/client"
     7  	"github.com/buildpacks/pack/pkg/logging"
     8  )
     9  
    10  // ManifestAdd adds a new image to a manifest list (image index).
    11  func ManifestAdd(logger logging.Logger, pack PackClient) *cobra.Command {
    12  	cmd := &cobra.Command{
    13  		Use:     "add [OPTIONS] <manifest-list> <manifest> [flags]",
    14  		Args:    cobra.MatchAll(cobra.ExactArgs(2), cobra.OnlyValidArgs),
    15  		Short:   "Add an image to a manifest list.",
    16  		Example: `pack manifest add my-image-index my-image:some-arch`,
    17  		RunE: logError(logger, func(cmd *cobra.Command, args []string) (err error) {
    18  			return pack.AddManifest(cmd.Context(), client.ManifestAddOptions{
    19  				IndexRepoName: args[0],
    20  				RepoName:      args[1],
    21  			})
    22  		}),
    23  	}
    24  
    25  	AddHelpFlag(cmd, "add")
    26  	return cmd
    27  }