2016-05-21 16:36:11 -04:00
|
|
|
package daemon
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
2017-05-16 19:56:56 -04:00
|
|
|
"runtime"
|
2016-05-21 16:36:11 -04:00
|
|
|
|
|
|
|
"github.com/docker/docker/image/tarexport"
|
2017-05-31 13:09:49 -04:00
|
|
|
"github.com/docker/docker/pkg/system"
|
2016-05-21 16:36:11 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// ExportImage exports a list of images to the given output stream. The
|
|
|
|
// exported images are archived into a tar when written to the output
|
|
|
|
// stream. All images with the given tag and all versions containing
|
|
|
|
// the same tag are exported. names is the set of tags to export, and
|
|
|
|
// outStream is the writer which the images are written to.
|
|
|
|
func (daemon *Daemon) ExportImage(names []string, outStream io.Writer) error {
|
2017-05-31 13:09:49 -04:00
|
|
|
// TODO @jhowardmsft LCOW. This will need revisiting later.
|
|
|
|
platform := runtime.GOOS
|
2017-06-26 12:11:54 -04:00
|
|
|
if system.LCOWSupported() {
|
2017-05-31 13:09:49 -04:00
|
|
|
platform = "linux"
|
|
|
|
}
|
|
|
|
imageExporter := tarexport.NewTarExporter(daemon.stores[platform].imageStore, daemon.stores[platform].layerStore, daemon.stores[platform].referenceStore, daemon)
|
2016-05-21 16:36:11 -04:00
|
|
|
return imageExporter.Save(names, outStream)
|
|
|
|
}
|
|
|
|
|
|
|
|
// LoadImage uploads a set of images into the repository. This is the
|
|
|
|
// complement of ImageExport. The input stream is an uncompressed tar
|
|
|
|
// ball containing images and metadata.
|
|
|
|
func (daemon *Daemon) LoadImage(inTar io.ReadCloser, outStream io.Writer, quiet bool) error {
|
2017-05-31 13:09:49 -04:00
|
|
|
// TODO @jhowardmsft LCOW. This will need revisiting later.
|
|
|
|
platform := runtime.GOOS
|
2017-06-26 12:11:54 -04:00
|
|
|
if system.LCOWSupported() {
|
2017-05-31 13:09:49 -04:00
|
|
|
platform = "linux"
|
|
|
|
}
|
|
|
|
imageExporter := tarexport.NewTarExporter(daemon.stores[platform].imageStore, daemon.stores[platform].layerStore, daemon.stores[platform].referenceStore, daemon)
|
2016-05-21 16:36:11 -04:00
|
|
|
return imageExporter.Load(inTar, outStream, quiet)
|
|
|
|
}
|