summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/compat/containers_archive.go
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2020-12-09 12:18:14 +0100
committerValentin Rothberg <rothberg@redhat.com>2020-12-09 14:05:17 +0100
commita12323884fd576063ba8f5785a3c9c2e48140c7f (patch)
treebbc773511eef8314bca1ef2e76bab68c766fe64b /pkg/api/handlers/compat/containers_archive.go
parentc2a5011c0d65cfd6c1ab5d6eef9778551ed56860 (diff)
downloadpodman-a12323884fd576063ba8f5785a3c9c2e48140c7f.tar.gz
podman-a12323884fd576063ba8f5785a3c9c2e48140c7f.tar.bz2
podman-a12323884fd576063ba8f5785a3c9c2e48140c7f.zip
pkg/copy: introduce a Copier
Introduce a `Copier` object to separate the copy-rule enforcement from copying. That allows for a better error reporting of the REST API. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'pkg/api/handlers/compat/containers_archive.go')
-rw-r--r--pkg/api/handlers/compat/containers_archive.go19
1 files changed, 15 insertions, 4 deletions
diff --git a/pkg/api/handlers/compat/containers_archive.go b/pkg/api/handlers/compat/containers_archive.go
index bb84f86be..d8197415c 100644
--- a/pkg/api/handlers/compat/containers_archive.go
+++ b/pkg/api/handlers/compat/containers_archive.go
@@ -10,6 +10,7 @@ import (
"github.com/containers/podman/v2/pkg/copy"
"github.com/gorilla/schema"
"github.com/pkg/errors"
+ "github.com/sirupsen/logrus"
)
func Archive(w http.ResponseWriter, r *http.Request) {
@@ -86,11 +87,16 @@ func handleHeadAndGet(w http.ResponseWriter, r *http.Request, decoder *schema.De
return
}
- w.WriteHeader(http.StatusOK)
- if err := copy.Copy(&source, &destination, false); err != nil {
+ copier, err := copy.GetCopier(&source, &destination, false)
+ if err != nil {
utils.Error(w, "Something went wrong", http.StatusInternalServerError, err)
return
}
+ w.WriteHeader(http.StatusOK)
+ if err := copier.Copy(); err != nil {
+ logrus.Errorf("Error during copy: %v", err)
+ return
+ }
}
func handlePut(w http.ResponseWriter, r *http.Request, decoder *schema.Decoder, runtime *libpod.Runtime) {
@@ -129,9 +135,14 @@ func handlePut(w http.ResponseWriter, r *http.Request, decoder *schema.Decoder,
return
}
- w.WriteHeader(http.StatusOK)
- if err := copy.Copy(&source, &destination, false); err != nil {
+ copier, err := copy.GetCopier(&source, &destination, false)
+ if err != nil {
utils.Error(w, "Something went wrong", http.StatusInternalServerError, err)
return
}
+ w.WriteHeader(http.StatusOK)
+ if err := copier.Copy(); err != nil {
+ logrus.Errorf("Error during copy: %v", err)
+ return
+ }
}