diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-04-01 22:54:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-01 22:54:22 +0200 |
commit | 0f357be5aeaa5dc651659cf0945a58780641e77d (patch) | |
tree | 77c502c42324db5aa5635b65f615c6a3c4e96fde /cmd/podmanV2/images/load.go | |
parent | 0a163720351710be314c729086e8d288680ff0a8 (diff) | |
parent | 8500ce6b9ab0050b925ec3b899495cb2cc8d367f (diff) | |
download | podman-0f357be5aeaa5dc651659cf0945a58780641e77d.tar.gz podman-0f357be5aeaa5dc651659cf0945a58780641e77d.tar.bz2 podman-0f357be5aeaa5dc651659cf0945a58780641e77d.zip |
Merge pull request #5686 from baude/v2load
podmanv2 load
Diffstat (limited to 'cmd/podmanV2/images/load.go')
-rw-r--r-- | cmd/podmanV2/images/load.go | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/cmd/podmanV2/images/load.go b/cmd/podmanV2/images/load.go new file mode 100644 index 000000000..f60dc4908 --- /dev/null +++ b/cmd/podmanV2/images/load.go @@ -0,0 +1,61 @@ +package images + +import ( + "context" + "fmt" + + "github.com/containers/libpod/cmd/podmanV2/registry" + "github.com/containers/libpod/libpod/image" + "github.com/containers/libpod/pkg/domain/entities" + "github.com/spf13/cobra" +) + +var ( + loadDescription = "Loads an image from a locally stored archive (tar file) into container storage." + loadCommand = &cobra.Command{ + Use: "load [flags] [NAME[:TAG]]", + Short: "Load an image from container archive", + Long: loadDescription, + RunE: load, + Args: cobra.MaximumNArgs(1), + PersistentPreRunE: preRunE, + } +) + +var ( + loadOpts entities.ImageLoadOptions +) + +func init() { + registry.Commands = append(registry.Commands, registry.CliCommand{ + Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, + Command: loadCommand, + }) + + loadCommand.SetHelpTemplate(registry.HelpTemplate()) + loadCommand.SetUsageTemplate(registry.UsageTemplate()) + flags := loadCommand.Flags() + flags.StringVarP(&loadOpts.Input, "input", "i", "", "Read from specified archive file (default: stdin)") + flags.BoolVarP(&loadOpts.Quiet, "quiet", "q", false, "Suppress the output") + flags.StringVar(&loadOpts.SignaturePolicy, "signature-policy", "", "Pathname of signature policy file") + if registry.IsRemote() { + _ = flags.MarkHidden("signature-policy") + } + +} + +func load(cmd *cobra.Command, args []string) error { + if len(args) > 0 { + repo, err := image.NormalizedTag(args[0]) + if err != nil { + return err + } + loadOpts.Name = repo.Name() + } + response, err := registry.ImageEngine().Load(context.Background(), loadOpts) + if err != nil { + return err + } + fmt.Println("Loaded image: " + response.Name) + return nil +} |