mirror of
https://github.com/containers/podman.git
synced 2025-10-17 03:04:21 +08:00
podman-remote save [image]
Add the ability to save an image from the remote-host to the remote-client. Signed-off-by: baude <bbaude@redhat.com>
This commit is contained in:
@ -4,12 +4,15 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/containers/storage/pkg/archive"
|
||||
systemdDbus "github.com/coreos/go-systemd/dbus"
|
||||
"github.com/godbus/dbus"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// ExecCmd executes a command with args and returns its output as a string along
|
||||
@ -139,3 +142,30 @@ func CopyDetachable(dst io.Writer, src io.Reader, keys []byte) (written int64, e
|
||||
}
|
||||
return written, err
|
||||
}
|
||||
|
||||
// UntarToFileSystem untars an os.file of a tarball to a destination in the filesystem
|
||||
func UntarToFileSystem(dest string, tarball *os.File, options *archive.TarOptions) error {
|
||||
logrus.Debugf("untarring %s", tarball.Name())
|
||||
return archive.Untar(tarball, dest, options)
|
||||
}
|
||||
|
||||
// TarToFilesystem creates a tarball from source and writes to an os.file
|
||||
// provided
|
||||
func TarToFilesystem(source string, tarball *os.File) error {
|
||||
tb, err := Tar(source)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = io.Copy(tarball, tb)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
logrus.Debugf("wrote tarball file %s", tarball.Name())
|
||||
return nil
|
||||
}
|
||||
|
||||
// Tar creates a tarball from source and returns a readcloser of it
|
||||
func Tar(source string) (io.ReadCloser, error) {
|
||||
logrus.Debugf("creating tarball of %s", source)
|
||||
return archive.Tar(source, archive.Uncompressed)
|
||||
}
|
||||
|
Reference in New Issue
Block a user