diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-02-05 19:33:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-05 19:33:06 +0100 |
commit | 650e242aa90fcb3f161da6e97921c606d3083215 (patch) | |
tree | 19a7bae6cd3bc117fa7b2e9dfe44d3534b4f75ed /pkg/varlinkapi/containers.go | |
parent | 3554bfce98bc643bd4724340bf2abbaa6373e70c (diff) | |
parent | 64c8fb7c2460eb561c8496f781f26d65443eea59 (diff) | |
download | podman-650e242aa90fcb3f161da6e97921c606d3083215.tar.gz podman-650e242aa90fcb3f161da6e97921c606d3083215.tar.bz2 podman-650e242aa90fcb3f161da6e97921c606d3083215.zip |
Merge pull request #2227 from baude/remoteexport
podman-remote import|export
Diffstat (limited to 'pkg/varlinkapi/containers.go')
-rw-r--r-- | pkg/varlinkapi/containers.go | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/pkg/varlinkapi/containers.go b/pkg/varlinkapi/containers.go index a01e3cc2b..737e2dd96 100644 --- a/pkg/varlinkapi/containers.go +++ b/pkg/varlinkapi/containers.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "io" + "io/ioutil" "os" "syscall" "time" @@ -194,15 +195,25 @@ func (i *LibpodAPI) ListContainerChanges(call iopodman.VarlinkCall, name string) } // ExportContainer ... -func (i *LibpodAPI) ExportContainer(call iopodman.VarlinkCall, name, path string) error { +func (i *LibpodAPI) ExportContainer(call iopodman.VarlinkCall, name, outPath string) error { ctr, err := i.Runtime.LookupContainer(name) if err != nil { return call.ReplyContainerNotFound(name) } - if err := ctr.Export(path); err != nil { + outputFile, err := ioutil.TempFile("", "varlink_recv") + if err != nil { + return call.ReplyErrorOccurred(err.Error()) + } + + defer outputFile.Close() + if outPath == "" { + outPath = outputFile.Name() + } + if err := ctr.Export(outPath); err != nil { return call.ReplyErrorOccurred(err.Error()) } - return call.ReplyExportContainer(path) + return call.ReplyExportContainer(outPath) + } // GetContainerStats ... |