LCOW: Plumb through platform on Import

Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
John Howard 2017-05-31 11:11:05 -07:00
parent a97b99e2d8
commit 3d5cec70b4
3 changed files with 13 additions and 17 deletions

View file

@ -35,7 +35,7 @@ type imageBackend interface {
type importExportBackend interface {
LoadImage(inTar io.ReadCloser, outStream io.Writer, quiet bool) error
ImportImage(src string, repository, tag string, msg string, inConfig io.ReadCloser, outStream io.Writer, changes []string) error
ImportImage(src string, repository, platform string, tag string, msg string, inConfig io.ReadCloser, outStream io.Writer, changes []string) error
ExportImage(names []string, outStream io.Writer) error
}

View file

@ -149,8 +149,7 @@ func (s *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWrite
// 'err' MUST NOT be defined within this block, we need any error
// generated from the download to be available to the output
// stream processing below
// TODO @jhowardmsft LCOW Support: This will need extending for the platform too.
err = s.backend.ImportImage(src, repo, tag, message, r.Body, output, r.Form["changes"])
err = s.backend.ImportImage(src, repo, platform, tag, message, r.Body, output, r.Form["changes"])
}
if err != nil {
if !output.Flushed() {

View file

@ -26,13 +26,18 @@ import (
// inConfig (if src is "-"), or from a URI specified in src. Progress output is
// written to outStream. Repository and tag names can optionally be given in
// the repo and tag arguments, respectively.
func (daemon *Daemon) ImportImage(src string, repository, tag string, msg string, inConfig io.ReadCloser, outStream io.Writer, changes []string) error {
func (daemon *Daemon) ImportImage(src string, repository, platform string, tag string, msg string, inConfig io.ReadCloser, outStream io.Writer, changes []string) error {
var (
rc io.ReadCloser
resp *http.Response
newRef reference.Named
)
// Default the platform if not supplied.
if platform == "" {
platform = runtime.GOOS
}
if repository != "" {
var err error
newRef, err = reference.ParseNormalizedNamed(repository)
@ -85,17 +90,11 @@ func (daemon *Daemon) ImportImage(src string, repository, tag string, msg string
if err != nil {
return err
}
// TODO: support windows baselayer?
// TODO: LCOW support @jhowardmsft. For now, pass in a null platform when
// registering the layer. Windows doesn't currently support import,
// but for Linux images, there's no reason it couldn't. However it
// would need another CLI flag as there's no meta-data indicating
// the OS of the thing being imported.
l, err := daemon.stores[runtime.GOOS].layerStore.Register(inflatedLayerData, "", "")
l, err := daemon.stores[platform].layerStore.Register(inflatedLayerData, "", layer.Platform(platform))
if err != nil {
return err
}
defer layer.ReleaseAndLog(daemon.stores[runtime.GOOS].layerStore, l) // TODO LCOW @jhowardmsft as for above comment
defer layer.ReleaseAndLog(daemon.stores[platform].layerStore, l)
created := time.Now().UTC()
imgConfig, err := json.Marshal(&image.Image{
@ -103,7 +102,7 @@ func (daemon *Daemon) ImportImage(src string, repository, tag string, msg string
DockerVersion: dockerversion.Version,
Config: config,
Architecture: runtime.GOARCH,
OS: runtime.GOOS, // TODO LCOW @jhowardmsft as for above commment
OS: platform,
Created: created,
Comment: msg,
},
@ -120,16 +119,14 @@ func (daemon *Daemon) ImportImage(src string, repository, tag string, msg string
return err
}
// TODO @jhowardmsft LCOW - Again, assume the OS of the host for now
id, err := daemon.stores[runtime.GOOS].imageStore.Create(imgConfig)
id, err := daemon.stores[platform].imageStore.Create(imgConfig)
if err != nil {
return err
}
// FIXME: connect with commit code and call refstore directly
if newRef != nil {
// TODO @jhowardmsft LCOW - Again, assume the OS of the host for now
if err := daemon.TagImageWithReference(id, runtime.GOOS, newRef); err != nil {
if err := daemon.TagImageWithReference(id, platform, newRef); err != nil {
return err
}
}