Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

podman load: support downloading files #12255

Merged
merged 1 commit into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions cmd/podman/images/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions docs/source/markdown/podman-load.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Note: `:` is a restricted character and cannot be part of the file name.

#### **--input**, **-i**=*input*

Read from archive file, default is STDIN.
Load the specified input file instead of from stdin. The file can be on the local file system or on a server (e.g., https://server.com/archive.tar)

The remote client requires the use of this option.

Expand All @@ -49,7 +49,7 @@ $ podman load --quiet -i fedora.tar
```

```
$ podman load -q -i fedora.tar
$ podman load -q -i https://server.com/archive.tar
```

```
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/containernetworking/cni v1.0.1
github.com/containernetworking/plugins v1.0.1
github.com/containers/buildah v1.23.1
github.com/containers/common v0.46.1-0.20211109131927-c342e496bf76
github.com/containers/common v0.46.1-0.20211110143743-73e7b462c358
github.com/containers/conmon v2.0.20+incompatible
github.com/containers/image/v5 v5.16.1
github.com/containers/ocicrypt v1.1.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ github.com/containernetworking/plugins v1.0.1/go.mod h1:QHCfGpaTwYTbbH+nZXKVTxNB
github.com/containers/buildah v1.23.1 h1:Tpc9DsRuU+0Oofewpxb6OJVNQjCu7yloN/obUqzfDTY=
github.com/containers/buildah v1.23.1/go.mod h1:4WnrN0yrA7ab0ppgunixu2WM1rlD2rG8QLJAKbEkZlQ=
github.com/containers/common v0.44.2/go.mod h1:7sdP4vmI5Bm6FPFxb3lvAh1Iktb6tiO1MzjUzhxdoGo=
github.com/containers/common v0.46.1-0.20211109131927-c342e496bf76 h1:5aDACNS6Rz+6f6rpgbv5tVG/zv1rFoPX1CYAy4Vv6ZI=
github.com/containers/common v0.46.1-0.20211109131927-c342e496bf76/go.mod h1:bu8gizEkgAz6gXHvUw2cMtI5ErxB+fn/hv49RWk5N1A=
github.com/containers/common v0.46.1-0.20211110143743-73e7b462c358 h1:dK2AgGBdWspdQNw28Wc4peY25QeyYV4H9ViQaFaQ9XQ=
github.com/containers/common v0.46.1-0.20211110143743-73e7b462c358/go.mod h1:bu8gizEkgAz6gXHvUw2cMtI5ErxB+fn/hv49RWk5N1A=
github.com/containers/conmon v2.0.20+incompatible h1:YbCVSFSCqFjjVwHTPINGdMX1F6JXHGTUje2ZYobNrkg=
github.com/containers/conmon v2.0.20+incompatible/go.mod h1:hgwZ2mtuDrppv78a/cOBNiCm6O0UMWGx1mu7P00nu5I=
github.com/containers/image/v5 v5.16.0/go.mod h1:XgTpfAPLRGOd1XYyCU5cISFr777bLmOerCSpt/v7+Q4=
Expand Down
20 changes: 20 additions & 0 deletions test/system/120-load.bats
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,26 @@ verify_iid_and_name() {
verify_iid_and_name $img_name
}

@test "podman load - from URL" {
get_iid_and_name
run_podman save $img_name -o $archive
run_podman rmi $iid

HOST_PORT=$(random_free_port)
SERVER=http://127.0.0.1:$HOST_PORT

# Bind-mount the archive to a container running httpd
run_podman run -d --name myweb -p "$HOST_PORT:80" \
-v $archive:/var/www/image.tar:Z \
-w /var/www \
$IMAGE /bin/busybox-extras httpd -f -p 80

run_podman load -i $SERVER/image.tar
verify_iid_and_name $img_name

run_podman rm -f -t0 myweb
}

@test "podman load - redirect corrupt payload" {
run_podman 125 load <<< "Danger, Will Robinson!! This is a corrupt tarball!"
is "$output" \
Expand Down
46 changes: 0 additions & 46 deletions vendor/github.com/containers/common/libimage/download.go

This file was deleted.

5 changes: 4 additions & 1 deletion vendor/github.com/containers/common/libimage/import.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vendor/github.com/containers/common/libimage/runtime.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions vendor/github.com/containers/common/pkg/config/config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/github.com/containers/common/pkg/config/default.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions vendor/github.com/containers/common/pkg/download/download.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions vendor/github.com/containers/common/pkg/seccomp/default_linux.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading