diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-11-10 18:27:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-10 18:27:39 +0100 |
commit | 4bf0146c2978960b8c4dc5a9844c4948effbcfd2 (patch) | |
tree | 1379f5b34f945ced30c2797432208203b02e1bf2 /cmd | |
parent | 2e6231bcbc05fe204a2b667252fb424b1a25cd00 (diff) | |
parent | 1ef66d6d7f215c51e582bdf21b04802b705881a4 (diff) | |
download | podman-4bf0146c2978960b8c4dc5a9844c4948effbcfd2.tar.gz podman-4bf0146c2978960b8c4dc5a9844c4948effbcfd2.tar.bz2 podman-4bf0146c2978960b8c4dc5a9844c4948effbcfd2.zip |
Merge pull request #12255 from vrothberg/fix-11970
podman load: support downloading files
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/images/load.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/cmd/podman/images/load.go b/cmd/podman/images/load.go index c7b7d6b3f..c39ae624e 100644 --- a/cmd/podman/images/load.go +++ b/cmd/podman/images/load.go @@ -9,6 +9,7 @@ import ( "strings" "github.com/containers/common/pkg/completion" + "github.com/containers/common/pkg/download" "github.com/containers/podman/v3/cmd/podman/registry" "github.com/containers/podman/v3/cmd/podman/validate" "github.com/containers/podman/v3/pkg/domain/entities" @@ -69,6 +70,20 @@ func loadFlags(cmd *cobra.Command) { func load(cmd *cobra.Command, args []string) error { if len(loadOpts.Input) > 0 { + // Download the input file if needed. + if strings.HasPrefix(loadOpts.Input, "https://") || strings.HasPrefix(loadOpts.Input, "http://") { + tmpdir, err := util.DefaultContainerConfig().ImageCopyTmpDir() + if err != nil { + return err + } + tmpfile, err := download.FromURL(tmpdir, loadOpts.Input) + if err != nil { + return err + } + defer os.Remove(tmpfile) + loadOpts.Input = tmpfile + } + if _, err := os.Stat(loadOpts.Input); err != nil { return err } |