Signed-off-by: John Howard <jhoward@microsoft.com>
John Howard authored on 2017/06/01 03:11:05... | ... |
@@ -35,7 +35,7 @@ type imageBackend interface { |
35 | 35 |
|
36 | 36 |
type importExportBackend interface { |
37 | 37 |
LoadImage(inTar io.ReadCloser, outStream io.Writer, quiet bool) error |
38 |
- ImportImage(src string, repository, tag string, msg string, inConfig io.ReadCloser, outStream io.Writer, changes []string) error |
|
38 |
+ ImportImage(src string, repository, platform string, tag string, msg string, inConfig io.ReadCloser, outStream io.Writer, changes []string) error |
|
39 | 39 |
ExportImage(names []string, outStream io.Writer) error |
40 | 40 |
} |
41 | 41 |
|
... | ... |
@@ -149,8 +149,7 @@ func (s *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWrite |
149 | 149 |
// 'err' MUST NOT be defined within this block, we need any error |
150 | 150 |
// generated from the download to be available to the output |
151 | 151 |
// stream processing below |
152 |
- // TODO @jhowardmsft LCOW Support: This will need extending for the platform too. |
|
153 |
- err = s.backend.ImportImage(src, repo, tag, message, r.Body, output, r.Form["changes"]) |
|
152 |
+ err = s.backend.ImportImage(src, repo, platform, tag, message, r.Body, output, r.Form["changes"]) |
|
154 | 153 |
} |
155 | 154 |
if err != nil { |
156 | 155 |
if !output.Flushed() { |
... | ... |
@@ -26,13 +26,18 @@ import ( |
26 | 26 |
// inConfig (if src is "-"), or from a URI specified in src. Progress output is |
27 | 27 |
// written to outStream. Repository and tag names can optionally be given in |
28 | 28 |
// the repo and tag arguments, respectively. |
29 |
-func (daemon *Daemon) ImportImage(src string, repository, tag string, msg string, inConfig io.ReadCloser, outStream io.Writer, changes []string) error { |
|
29 |
+func (daemon *Daemon) ImportImage(src string, repository, platform string, tag string, msg string, inConfig io.ReadCloser, outStream io.Writer, changes []string) error { |
|
30 | 30 |
var ( |
31 | 31 |
rc io.ReadCloser |
32 | 32 |
resp *http.Response |
33 | 33 |
newRef reference.Named |
34 | 34 |
) |
35 | 35 |
|
36 |
+ // Default the platform if not supplied. |
|
37 |
+ if platform == "" { |
|
38 |
+ platform = runtime.GOOS |
|
39 |
+ } |
|
40 |
+ |
|
36 | 41 |
if repository != "" { |
37 | 42 |
var err error |
38 | 43 |
newRef, err = reference.ParseNormalizedNamed(repository) |
... | ... |
@@ -85,17 +90,11 @@ func (daemon *Daemon) ImportImage(src string, repository, tag string, msg string |
85 | 85 |
if err != nil { |
86 | 86 |
return err |
87 | 87 |
} |
88 |
- // TODO: support windows baselayer? |
|
89 |
- // TODO: LCOW support @jhowardmsft. For now, pass in a null platform when |
|
90 |
- // registering the layer. Windows doesn't currently support import, |
|
91 |
- // but for Linux images, there's no reason it couldn't. However it |
|
92 |
- // would need another CLI flag as there's no meta-data indicating |
|
93 |
- // the OS of the thing being imported. |
|
94 |
- l, err := daemon.stores[runtime.GOOS].layerStore.Register(inflatedLayerData, "", "") |
|
88 |
+ l, err := daemon.stores[platform].layerStore.Register(inflatedLayerData, "", layer.Platform(platform)) |
|
95 | 89 |
if err != nil { |
96 | 90 |
return err |
97 | 91 |
} |
98 |
- defer layer.ReleaseAndLog(daemon.stores[runtime.GOOS].layerStore, l) // TODO LCOW @jhowardmsft as for above comment |
|
92 |
+ defer layer.ReleaseAndLog(daemon.stores[platform].layerStore, l) |
|
99 | 93 |
|
100 | 94 |
created := time.Now().UTC() |
101 | 95 |
imgConfig, err := json.Marshal(&image.Image{ |
... | ... |
@@ -103,7 +102,7 @@ func (daemon *Daemon) ImportImage(src string, repository, tag string, msg string |
103 | 103 |
DockerVersion: dockerversion.Version, |
104 | 104 |
Config: config, |
105 | 105 |
Architecture: runtime.GOARCH, |
106 |
- OS: runtime.GOOS, // TODO LCOW @jhowardmsft as for above commment |
|
106 |
+ OS: platform, |
|
107 | 107 |
Created: created, |
108 | 108 |
Comment: msg, |
109 | 109 |
}, |
... | ... |
@@ -120,16 +119,14 @@ func (daemon *Daemon) ImportImage(src string, repository, tag string, msg string |
120 | 120 |
return err |
121 | 121 |
} |
122 | 122 |
|
123 |
- // TODO @jhowardmsft LCOW - Again, assume the OS of the host for now |
|
124 |
- id, err := daemon.stores[runtime.GOOS].imageStore.Create(imgConfig) |
|
123 |
+ id, err := daemon.stores[platform].imageStore.Create(imgConfig) |
|
125 | 124 |
if err != nil { |
126 | 125 |
return err |
127 | 126 |
} |
128 | 127 |
|
129 | 128 |
// FIXME: connect with commit code and call refstore directly |
130 | 129 |
if newRef != nil { |
131 |
- // TODO @jhowardmsft LCOW - Again, assume the OS of the host for now |
|
132 |
- if err := daemon.TagImageWithReference(id, runtime.GOOS, newRef); err != nil { |
|
130 |
+ if err := daemon.TagImageWithReference(id, platform, newRef); err != nil { |
|
133 | 131 |
return err |
134 | 132 |
} |
135 | 133 |
} |