github.com/buildpacks/pack@v0.33.3-0.20240516162812-884dd1837311/internal/commands/manifest_push.go (about) 1 package commands 2 3 import ( 4 "strings" 5 6 "github.com/spf13/cobra" 7 8 "github.com/buildpacks/pack/pkg/client" 9 "github.com/buildpacks/pack/pkg/logging" 10 ) 11 12 // ManifestPushFlags define flags provided to the ManifestPush 13 type ManifestPushFlags struct { 14 format string 15 insecure, purge bool 16 } 17 18 // ManifestPush pushes a manifest list to a remote registry. 19 func ManifestPush(logger logging.Logger, pack PackClient) *cobra.Command { 20 var flags ManifestPushFlags 21 22 cmd := &cobra.Command{ 23 Use: "push [OPTIONS] <manifest-list> [flags]", 24 Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs), 25 Short: "Push a manifest list to a registry.", 26 Example: `pack manifest push my-image-index`, 27 Long: `manifest push' pushes a manifest list to a registry. 28 Use other 'pack manifest' commands to prepare the manifest list locally, then use the push command.`, 29 RunE: logError(logger, func(cmd *cobra.Command, args []string) error { 30 format, err := parseFormatFlag(strings.ToLower(flags.format)) 31 if err != nil { 32 return err 33 } 34 35 return pack.PushManifest(client.PushManifestOptions{ 36 IndexRepoName: args[0], 37 Format: format, 38 Insecure: flags.insecure, 39 Purge: flags.purge, 40 }) 41 }), 42 } 43 44 cmd.Flags().StringVarP(&flags.format, "format", "f", "oci", "Media type to use when saving the image index. Accepted values are: oci, docker") 45 cmd.Flags().BoolVar(&flags.insecure, "insecure", false, "When pushing the index to a registry, do not use TLS encryption or certificate verification") 46 cmd.Flags().BoolVar(&flags.purge, "purge", false, "Delete the manifest list from local storage if pushing succeeds") 47 48 AddHelpFlag(cmd, "push") 49 return cmd 50 }