|
@@ -26,13 +26,18 @@ import (
|
|
// inConfig (if src is "-"), or from a URI specified in src. Progress output is
|
|
// 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
|
|
// written to outStream. Repository and tag names can optionally be given in
|
|
// the repo and tag arguments, respectively.
|
|
// 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 (
|
|
var (
|
|
rc io.ReadCloser
|
|
rc io.ReadCloser
|
|
resp *http.Response
|
|
resp *http.Response
|
|
newRef reference.Named
|
|
newRef reference.Named
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+ // Default the platform if not supplied.
|
|
|
|
+ if platform == "" {
|
|
|
|
+ platform = runtime.GOOS
|
|
|
|
+ }
|
|
|
|
+
|
|
if repository != "" {
|
|
if repository != "" {
|
|
var err error
|
|
var err error
|
|
newRef, err = reference.ParseNormalizedNamed(repository)
|
|
newRef, err = reference.ParseNormalizedNamed(repository)
|
|
@@ -85,17 +90,11 @@ func (daemon *Daemon) ImportImage(src string, repository, tag string, msg string
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
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 {
|
|
if err != nil {
|
|
return err
|
|
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()
|
|
created := time.Now().UTC()
|
|
imgConfig, err := json.Marshal(&image.Image{
|
|
imgConfig, err := json.Marshal(&image.Image{
|
|
@@ -103,7 +102,7 @@ func (daemon *Daemon) ImportImage(src string, repository, tag string, msg string
|
|
DockerVersion: dockerversion.Version,
|
|
DockerVersion: dockerversion.Version,
|
|
Config: config,
|
|
Config: config,
|
|
Architecture: runtime.GOARCH,
|
|
Architecture: runtime.GOARCH,
|
|
- OS: runtime.GOOS, // TODO LCOW @jhowardmsft as for above commment
|
|
|
|
|
|
+ OS: platform,
|
|
Created: created,
|
|
Created: created,
|
|
Comment: msg,
|
|
Comment: msg,
|
|
},
|
|
},
|
|
@@ -120,16 +119,14 @@ func (daemon *Daemon) ImportImage(src string, repository, tag string, msg string
|
|
return err
|
|
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 {
|
|
if err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
|
|
|
|
// FIXME: connect with commit code and call refstore directly
|
|
// FIXME: connect with commit code and call refstore directly
|
|
if newRef != nil {
|
|
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
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
}
|