diff options
author | baude <bbaude@redhat.com> | 2019-02-19 13:36:42 -0600 |
---|---|---|
committer | baude <bbaude@redhat.com> | 2019-02-21 10:11:19 -0600 |
commit | 71db80ddb15addb4197693bc056c35dd8ff0d6ac (patch) | |
tree | 9b3614c1c806dca4bf4745448d9e57c82d6fe2d3 /cmd | |
parent | af922fb2c6baceb89cc8e4acd6d84a6474b32dda (diff) | |
download | podman-71db80ddb15addb4197693bc056c35dd8ff0d6ac.tar.gz podman-71db80ddb15addb4197693bc056c35dd8ff0d6ac.tar.bz2 podman-71db80ddb15addb4197693bc056c35dd8ff0d6ac.zip |
podman-remote load image
enable the ability to load an image into remote storage
using the remote client.
Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/commands.go | 1 | ||||
-rw-r--r-- | cmd/podman/image.go | 1 | ||||
-rw-r--r-- | cmd/podman/load.go | 54 | ||||
-rw-r--r-- | cmd/podman/main.go | 1 | ||||
-rw-r--r-- | cmd/podman/varlink/io.podman.varlink | 3 |
5 files changed, 13 insertions, 47 deletions
diff --git a/cmd/podman/commands.go b/cmd/podman/commands.go index 466ffa22f..0dc241373 100644 --- a/cmd/podman/commands.go +++ b/cmd/podman/commands.go @@ -17,7 +17,6 @@ func getMainCommands() []*cobra.Command { generateCommand.Command, _containerKubeCommand, _psCommand, - _loadCommand, _loginCommand, _logoutCommand, _logsCommand, diff --git a/cmd/podman/image.go b/cmd/podman/image.go index 3c8942ef5..14053cb0d 100644 --- a/cmd/podman/image.go +++ b/cmd/podman/image.go @@ -24,6 +24,7 @@ var imageSubCommands = []*cobra.Command{ _imagesCommand, _importCommand, _inspectCommand, + _loadCommand, _pruneImagesCommand, _pullCommand, _pushCommand, diff --git a/cmd/podman/load.go b/cmd/podman/load.go index 34a51cd0d..514c9f1e9 100644 --- a/cmd/podman/load.go +++ b/cmd/podman/load.go @@ -6,12 +6,8 @@ import ( "io/ioutil" "os" - "github.com/containers/image/directory" - dockerarchive "github.com/containers/image/docker/archive" - ociarchive "github.com/containers/image/oci/archive" "github.com/containers/libpod/cmd/podman/cliconfig" - "github.com/containers/libpod/cmd/podman/libpodruntime" - "github.com/containers/libpod/libpod/image" + "github.com/containers/libpod/libpod/adapter" "github.com/pkg/errors" "github.com/spf13/cobra" ) @@ -56,14 +52,16 @@ func loadCmd(c *cliconfig.LoadValues) error { return errors.New("too many arguments. Requires exactly 1") } - runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(&c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } defer runtime.Shutdown(false) input := c.Input - + if runtime.Remote && len(input) == 0 { + return errors.New("the remote client requires you to load via -i and a tarball") + } if input == "/dev/stdin" { fi, err := os.Stdin.Stat() if err != nil { @@ -96,46 +94,10 @@ func loadCmd(c *cliconfig.LoadValues) error { return err } - var writer io.Writer - if !c.Quiet { - writer = os.Stderr - } - - ctx := getContext() - - var newImages []*image.Image - src, err := dockerarchive.ParseReference(input) // FIXME? We should add dockerarchive.NewReference() - if err == nil { - newImages, err = runtime.ImageRuntime().LoadFromArchiveReference(ctx, src, c.SignaturePolicy, writer) - } + names, err := runtime.LoadImage(getContext(), imageName, c) if err != nil { - // generate full src name with specified image:tag - src, err := ociarchive.NewReference(input, imageName) // imageName may be "" - if err == nil { - newImages, err = runtime.ImageRuntime().LoadFromArchiveReference(ctx, src, c.SignaturePolicy, writer) - } - if err != nil { - src, err := directory.NewReference(input) - if err == nil { - newImages, err = runtime.ImageRuntime().LoadFromArchiveReference(ctx, src, c.SignaturePolicy, writer) - } - if err != nil { - return errors.Wrapf(err, "error pulling %q", input) - } - } + return err } - fmt.Println("Loaded image(s): " + getImageNames(newImages)) + fmt.Println("Loaded image(s): " + names) return nil } - -func getImageNames(images []*image.Image) string { - var names string - for i := range images { - if i == 0 { - names = images[i].InputName - } else { - names += ", " + images[i].InputName - } - } - return names -} diff --git a/cmd/podman/main.go b/cmd/podman/main.go index b60f3e1e1..990e55a8c 100644 --- a/cmd/podman/main.go +++ b/cmd/podman/main.go @@ -45,6 +45,7 @@ var mainCommands = []*cobra.Command{ _infoCommand, _inspectCommand, _killCommand, + _loadCommand, podCommand.Command, _pullCommand, _pushCommand, diff --git a/cmd/podman/varlink/io.podman.varlink b/cmd/podman/varlink/io.podman.varlink index 53c21cb21..09d178760 100644 --- a/cmd/podman/varlink/io.podman.varlink +++ b/cmd/podman/varlink/io.podman.varlink @@ -1102,8 +1102,11 @@ method VolumesPrune() -> (prunedNames: []string, prunedErrors: []string) method ImageSave(options: ImageSaveOptions) -> (reply: MoreResponse) + method GetPodsByContext(all: bool, latest: bool, args: []string) -> (pods: []string) +method LoadImage(name: string, inputFile: string, quiet: bool, deleteFile: bool) -> (reply: MoreResponse) + # ImageNotFound means the image could not be found by the provided name or ID in local storage. error ImageNotFound (id: string) |