diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-07-24 05:53:16 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-24 05:53:16 -0400 |
commit | c44c298ae7b5ce1da2aeff5b920de65767966007 (patch) | |
tree | 3c949238461e4d6bfc63a2dc49fb9628b44e9ace /cmd/podman/images/import.go | |
parent | 2f79497aba90229664c35fb738704d61e4528f44 (diff) | |
parent | dcb5c92c0d94c81f0706cd282b55a2a9d1fde30f (diff) | |
download | podman-c44c298ae7b5ce1da2aeff5b920de65767966007.tar.gz podman-c44c298ae7b5ce1da2aeff5b920de65767966007.tar.bz2 podman-c44c298ae7b5ce1da2aeff5b920de65767966007.zip |
Merge pull request #11018 from vrothberg/fix-10994
import: write stdin to tmp file
Diffstat (limited to 'cmd/podman/images/import.go')
-rw-r--r-- | cmd/podman/images/import.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/cmd/podman/images/import.go b/cmd/podman/images/import.go index bed2d4105..bc80417cc 100644 --- a/cmd/podman/images/import.go +++ b/cmd/podman/images/import.go @@ -3,6 +3,9 @@ package images import ( "context" "fmt" + "io" + "io/ioutil" + "os" "strings" "github.com/containers/common/pkg/completion" @@ -97,6 +100,22 @@ func importCon(cmd *cobra.Command, args []string) error { default: return errors.Errorf("too many arguments. Usage TARBALL [REFERENCE]") } + + if source == "-" { + outFile, err := ioutil.TempFile("", "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) + } + source = outFile.Name() + } + errFileName := parse.ValidateFileName(source) errURL := parse.ValidURL(source) if errURL == nil { |