summaryrefslogtreecommitdiff
path: root/pkg/bindings
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2020-03-31 19:13:19 -0500
committerBrent Baude <bbaude@redhat.com>2020-04-01 16:02:53 -0500
commitbb39051616fbce12b4cb3135a62c7747273ab0aa (patch)
tree055e000b03084fbd41cd7f9b6cf8c3c407f397c0 /pkg/bindings
parent0f357be5aeaa5dc651659cf0945a58780641e77d (diff)
downloadpodman-bb39051616fbce12b4cb3135a62c7747273ab0aa.tar.gz
podman-bb39051616fbce12b4cb3135a62c7747273ab0aa.tar.bz2
podman-bb39051616fbce12b4cb3135a62c7747273ab0aa.zip
podmanv2 export
add ability to export a container to a tarball Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/bindings')
-rw-r--r--pkg/bindings/containers/containers.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/pkg/bindings/containers/containers.go b/pkg/bindings/containers/containers.go
index bad1294f4..49a2dfd58 100644
--- a/pkg/bindings/containers/containers.go
+++ b/pkg/bindings/containers/containers.go
@@ -2,6 +2,7 @@ package containers
import (
"context"
+ "io"
"net/http"
"net/url"
"strconv"
@@ -296,3 +297,22 @@ func Stop(ctx context.Context, nameOrID string, timeout *uint) error {
}
return response.Process(nil)
}
+
+// Export creates a tarball of the given name or ID of a container. It
+// requires an io.Writer be provided to write the tarball.
+func Export(ctx context.Context, nameOrID string, w io.Writer) error {
+ params := url.Values{}
+ conn, err := bindings.GetClient(ctx)
+ if err != nil {
+ return err
+ }
+ response, err := conn.DoRequest(nil, http.MethodGet, "/containers/%s/export", params, nameOrID)
+ if err != nil {
+ return err
+ }
+ if response.StatusCode/100 == 2 {
+ _, err = io.Copy(w, response.Body)
+ return err
+ }
+ return response.Process(nil)
+}