diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-04-13 21:57:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-13 21:57:39 +0200 |
commit | 0b067b67e6fa9e7ce8c1b460f5347c8ae89d1ecb (patch) | |
tree | 6d777c6e7bf9d542633a936a0bb03decceaeaaa8 /cmd/podmanV2/images/load.go | |
parent | d7695dd957b162ed24c807dc91200fe1abaecff1 (diff) | |
parent | 90ead05903e9c42758c1052c2ee623dca8de5e98 (diff) | |
download | podman-0b067b67e6fa9e7ce8c1b460f5347c8ae89d1ecb.tar.gz podman-0b067b67e6fa9e7ce8c1b460f5347c8ae89d1ecb.tar.bz2 podman-0b067b67e6fa9e7ce8c1b460f5347c8ae89d1ecb.zip |
Merge pull request #5800 from baude/v2edtests
Fixes for load and other system tests
Diffstat (limited to 'cmd/podmanV2/images/load.go')
-rw-r--r-- | cmd/podmanV2/images/load.go | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/cmd/podmanV2/images/load.go b/cmd/podmanV2/images/load.go index f60dc4908..315dbed3a 100644 --- a/cmd/podmanV2/images/load.go +++ b/cmd/podmanV2/images/load.go @@ -3,11 +3,18 @@ package images import ( "context" "fmt" + "io" + "io/ioutil" + "os" + "github.com/containers/image/v5/docker/reference" + "github.com/containers/libpod/cmd/podmanV2/parse" "github.com/containers/libpod/cmd/podmanV2/registry" - "github.com/containers/libpod/libpod/image" "github.com/containers/libpod/pkg/domain/entities" + "github.com/containers/libpod/pkg/util" + "github.com/pkg/errors" "github.com/spf13/cobra" + "golang.org/x/crypto/ssh/terminal" ) var ( @@ -46,11 +53,40 @@ func init() { func load(cmd *cobra.Command, args []string) error { if len(args) > 0 { - repo, err := image.NormalizedTag(args[0]) + ref, err := reference.Parse(args[0]) if err != nil { return err } - loadOpts.Name = repo.Name() + if t, ok := ref.(reference.Tagged); ok { + loadOpts.Tag = t.Tag() + } else { + loadOpts.Tag = "latest" + } + if r, ok := ref.(reference.Named); ok { + fmt.Println(r.Name()) + loadOpts.Name = r.Name() + } + } + if len(loadOpts.Input) > 0 { + if err := parse.ValidateFileName(loadOpts.Input); err != nil { + return err + } + } else { + if terminal.IsTerminal(int(os.Stdin.Fd())) { + return errors.Errorf("cannot read from terminal. Use command-line redirection or the --input flag.") + } + outFile, err := ioutil.TempFile(util.Tmpdir(), "podman") + if err != nil { + return errors.Errorf("error creating file %v", err) + } + defer os.Remove(outFile.Name()) + defer outFile.Close() + + _, err = io.Copy(outFile, os.Stdin) + if err != nil { + return errors.Errorf("error copying file %v", err) + } + loadOpts.Input = outFile.Name() } response, err := registry.ImageEngine().Load(context.Background(), loadOpts) if err != nil { |