summaryrefslogtreecommitdiff
path: root/cmd/podman/images/load.go
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2021-11-10 15:39:29 +0100
committerValentin Rothberg <rothberg@redhat.com>2021-11-10 15:43:16 +0100
commit1ef66d6d7f215c51e582bdf21b04802b705881a4 (patch)
treeb8c18c0fa378987d70c3308d344219410f3c56aa /cmd/podman/images/load.go
parent5437568fcda04c2999b5fa9aad4dd07f2d3cfd67 (diff)
downloadpodman-1ef66d6d7f215c51e582bdf21b04802b705881a4.tar.gz
podman-1ef66d6d7f215c51e582bdf21b04802b705881a4.tar.bz2
podman-1ef66d6d7f215c51e582bdf21b04802b705881a4.zip
podman load: support downloading files
Support downloading files, for instance via `podman load -i server.com/image.tar`. The specified URL is downloaded in the frontend and stored as a temp file that gets passed down to the backend. Also vendor in c/common@main to use the new `pkg/download`. Fixes: #11970 Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'cmd/podman/images/load.go')
-rw-r--r--cmd/podman/images/load.go15
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
}