summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.cirrus.yml2
-rw-r--r--cmd/podman/images/save.go7
-rw-r--r--pkg/api/server/handler_api.go17
-rw-r--r--test/system/120-load.bats41
4 files changed, 53 insertions, 14 deletions
diff --git a/.cirrus.yml b/.cirrus.yml
index a11bbbe61..8b1036d7c 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -39,7 +39,7 @@ env:
UBUNTU_NAME: "ubuntu"
PRIOR_UBUNTU_NAME: "prior-ubuntu"
- _BUILT_IMAGE_SUFFIX: "c5809900649447424"
+ _BUILT_IMAGE_SUFFIX: "c6110627968057344"
FEDORA_CACHE_IMAGE_NAME: "${FEDORA_NAME}-${_BUILT_IMAGE_SUFFIX}"
PRIOR_FEDORA_CACHE_IMAGE_NAME: "${PRIOR_FEDORA_NAME}-${_BUILT_IMAGE_SUFFIX}"
UBUNTU_CACHE_IMAGE_NAME: "${UBUNTU_NAME}-${_BUILT_IMAGE_SUFFIX}"
diff --git a/cmd/podman/images/save.go b/cmd/podman/images/save.go
index c57f61221..b164a2534 100644
--- a/cmd/podman/images/save.go
+++ b/cmd/podman/images/save.go
@@ -94,6 +94,7 @@ func save(cmd *cobra.Command, args []string) (finalErr error) {
return errors.Errorf("--compress can only be set when --format is either 'oci-dir' or 'docker-dir'")
}
if len(saveOpts.Output) == 0 {
+ saveOpts.Quiet = true
fi := os.Stdout
if terminal.IsTerminal(int(fi.Fd())) {
return errors.Errorf("refusing to save to terminal. Use -o flag or redirect")
@@ -122,12 +123,6 @@ func save(cmd *cobra.Command, args []string) (finalErr error) {
tags = args[1:]
}
- // Decide whether c/image's progress bars should use stderr or stdout.
- // If the output is set of stdout, any log message there would corrupt
- // the tarfile.
- if saveOpts.Output == os.Stdout.Name() {
- saveOpts.Quiet = true
- }
err := registry.ImageEngine().Save(context.Background(), args[0], tags, saveOpts)
if err == nil {
succeeded = true
diff --git a/pkg/api/server/handler_api.go b/pkg/api/server/handler_api.go
index f2ce0301b..920811c51 100644
--- a/pkg/api/server/handler_api.go
+++ b/pkg/api/server/handler_api.go
@@ -34,15 +34,18 @@ func (s *APIServer) APIHandler(h http.HandlerFunc) http.HandlerFunc {
}
// TODO: Use r.ConnContext when ported to go 1.13
- c := context.WithValue(r.Context(), "decoder", s.Decoder) //nolint
- c = context.WithValue(c, "runtime", s.Runtime) //nolint
- c = context.WithValue(c, "shutdownFunc", s.Shutdown) //nolint
- c = context.WithValue(c, "idletracker", s.idleTracker) //nolint
+ c := context.WithValue(r.Context(), "decoder", s.Decoder) // nolint
+ c = context.WithValue(c, "runtime", s.Runtime) // nolint
+ c = context.WithValue(c, "shutdownFunc", s.Shutdown) // nolint
+ c = context.WithValue(c, "idletracker", s.idleTracker) // nolint
r = r.WithContext(c)
- v := utils.APIVersion[utils.CompatTree][utils.CurrentAPIVersion]
- w.Header().Set("API-Version", fmt.Sprintf("%d.%d", v.Major, v.Minor))
- w.Header().Set("Libpod-API-Version", utils.APIVersion[utils.LibpodTree][utils.CurrentAPIVersion].String())
+ cv := utils.APIVersion[utils.CompatTree][utils.CurrentAPIVersion]
+ w.Header().Set("API-Version", fmt.Sprintf("%d.%d", cv.Major, cv.Minor))
+
+ lv := utils.APIVersion[utils.LibpodTree][utils.CurrentAPIVersion].String()
+ w.Header().Set("Libpod-API-Version", lv)
+ w.Header().Set("Server", "Libpod/"+lv+" ("+runtime.GOOS+")")
h(w, r)
}
diff --git a/test/system/120-load.bats b/test/system/120-load.bats
index d7aa16d95..8ea9b1c69 100644
--- a/test/system/120-load.bats
+++ b/test/system/120-load.bats
@@ -147,4 +147,45 @@ verify_iid_and_name() {
"Diagnostic from 'podman load' without redirection or -i"
}
+@test "podman load - multi-image archive" {
+ img1="quay.io/libpod/testimage:00000000"
+ img2="quay.io/libpod/testimage:20200902"
+ archive=$PODMAN_TMPDIR/myimage-$(random_string 8).tar
+
+ run_podman pull $img1
+ run_podman pull $img2
+
+ run_podman save -m -o $archive $img1 $img2
+ run_podman rmi -f $img1 $img2
+ run_podman load -i $archive
+
+ run_podman image exists $img1
+ run_podman image exists $img2
+ run_podman rmi -f $img1 $img2
+}
+
+@test "podman load - multi-image archive with redirect" {
+ img1="quay.io/libpod/testimage:00000000"
+ img2="quay.io/libpod/testimage:20200902"
+ archive=$PODMAN_TMPDIR/myimage-$(random_string 8).tar
+
+ run_podman pull $img1
+ run_podman pull $img2
+
+ # We can't use run_podman because that uses the BATS 'run' function
+ # which redirects stdout and stderr. Here we need to guarantee
+ # that podman's stdout is a pipe, not any other form of redirection
+ $PODMAN save -m $img1 $img2 | cat >$archive
+ if [ "$status" -ne 0 ]; then
+ die "Command failed: podman save ... | cat"
+ fi
+
+ run_podman rmi -f $img1 $img2
+ run_podman load -i $archive
+
+ run_podman image exists $img1
+ run_podman image exists $img2
+ run_podman rmi -f $img1 $img2
+}
+
# vim: filetype=sh