diff --git a/api/server/router/image/backend.go b/api/server/router/image/backend.go index b791c7af1c..9a588a71a9 100644 --- a/api/server/router/image/backend.go +++ b/api/server/router/image/backend.go @@ -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 } diff --git a/api/server/router/image/image_routes.go b/api/server/router/image/image_routes.go index e0012dfdb9..232d795683 100644 --- a/api/server/router/image/image_routes.go +++ b/api/server/router/image/image_routes.go @@ -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() { diff --git a/daemon/import.go b/daemon/import.go index 1923bce172..0409cd6bd6 100644 --- a/daemon/import.go +++ b/daemon/import.go @@ -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 } }