get.porter.sh/porter@v1.3.0/cmd/porter/copy.go (about) 1 package main 2 3 import ( 4 "get.porter.sh/porter/pkg/porter" 5 "github.com/spf13/cobra" 6 ) 7 8 func buildBundleCopyCommand(p *porter.Porter) *cobra.Command { 9 10 opts := &porter.CopyOpts{} 11 12 cmd := cobra.Command{ 13 Use: "copy", 14 Short: "Copy a bundle", 15 Long: `Copy a published bundle from one registry to another. 16 Source bundle can be either a tagged reference or a digest reference. 17 Destination can be either a registry, a registry/repository, or a fully tagged bundle reference. 18 If the source bundle is a digest reference, destination must be a tagged reference. 19 `, 20 Example: ` porter bundle copy 21 porter bundle copy --source ghcr.io/getporter/examples/porter-hello:v0.2.0 --destination portersh 22 porter bundle copy --source ghcr.io/getporter/examples/porter-hello:v0.2.0 --destination portersh --insecure-registry 23 `, 24 PreRunE: func(cmd *cobra.Command, args []string) error { 25 return opts.Validate(p.Config) 26 }, 27 RunE: func(cmd *cobra.Command, args []string) error { 28 return p.CopyBundle(cmd.Context(), opts) 29 }, 30 } 31 f := cmd.Flags() 32 f.StringVarP(&opts.Source, "source", "", "", " The fully qualified source bundle, including tag or digest.") 33 f.StringVarP(&opts.Destination, "destination", "", "", "The registry to copy the bundle to. Can be registry name, registry plus a repo prefix, or a new tagged reference. All images and the bundle will be prefixed with registry.") 34 f.BoolVar(&opts.InsecureRegistry, "insecure-registry", false, "Don't require TLS for registries") 35 f.BoolVar(&opts.Force, "force", false, "Force push the bundle to overwrite the previously published bundle") 36 // Allow configuring the --force flag with "force-overwrite" in the configuration file 37 cmd.Flag("force").Annotations = map[string][]string{ 38 "viper-key": {"force-overwrite"}, 39 } 40 f.BoolVar(&opts.SignBundle, "sign-bundle", false, "Sign the bundle using the configured signing plugin") 41 42 return &cmd 43 }