Signed-off-by: John Howard <jhoward@microsoft.com>
| ... | ... |
@@ -78,7 +78,7 @@ type Result struct {
|
| 78 | 78 |
// ImageCacheBuilder represents a generator for stateful image cache. |
| 79 | 79 |
type ImageCacheBuilder interface {
|
| 80 | 80 |
// MakeImageCache creates a stateful image cache. |
| 81 |
- MakeImageCache(cacheFrom []string) ImageCache |
|
| 81 |
+ MakeImageCache(cacheFrom []string, platform string) ImageCache |
|
| 82 | 82 |
} |
| 83 | 83 |
|
| 84 | 84 |
// ImageCache abstracts an image cache. |
| ... | ... |
@@ -166,7 +166,7 @@ func newBuilder(clientCtx context.Context, options builderOptions) *Builder {
|
| 166 | 166 |
buildStages: newBuildStages(), |
| 167 | 167 |
imageSources: newImageSources(clientCtx, options), |
| 168 | 168 |
pathCache: options.PathCache, |
| 169 |
- imageProber: newImageProber(options.Backend, config.CacheFrom, config.NoCache), |
|
| 169 |
+ imageProber: newImageProber(options.Backend, config.CacheFrom, options.Platform, config.NoCache), |
|
| 170 | 170 |
containerManager: newContainerManager(options.Backend), |
| 171 | 171 |
platform: options.Platform, |
| 172 | 172 |
} |
| ... | ... |
@@ -63,7 +63,7 @@ func newBuilderWithMockBackend() *Builder {
|
| 63 | 63 |
Backend: mockBackend, |
| 64 | 64 |
}), |
| 65 | 65 |
buildStages: newBuildStages(), |
| 66 |
- imageProber: newImageProber(mockBackend, nil, false), |
|
| 66 |
+ imageProber: newImageProber(mockBackend, nil, runtime.GOOS, false), |
|
| 67 | 67 |
containerManager: newContainerManager(mockBackend), |
| 68 | 68 |
} |
| 69 | 69 |
return b |
| ... | ... |
@@ -488,10 +488,10 @@ func TestRunWithBuildArgs(t *testing.T) {
|
| 488 | 488 |
} |
| 489 | 489 |
|
| 490 | 490 |
mockBackend := b.docker.(*MockBackend) |
| 491 |
- mockBackend.makeImageCacheFunc = func(_ []string) builder.ImageCache {
|
|
| 491 |
+ mockBackend.makeImageCacheFunc = func(_ []string, _ string) builder.ImageCache {
|
|
| 492 | 492 |
return imageCache |
| 493 | 493 |
} |
| 494 |
- b.imageProber = newImageProber(mockBackend, nil, false) |
|
| 494 |
+ b.imageProber = newImageProber(mockBackend, nil, runtime.GOOS, false) |
|
| 495 | 495 |
mockBackend.getImageFunc = func(_ string) (builder.Image, builder.ReleaseableLayer, error) {
|
| 496 | 496 |
return &mockImage{
|
| 497 | 497 |
id: "abcdef", |
| ... | ... |
@@ -19,13 +19,13 @@ type imageProber struct {
|
| 19 | 19 |
cacheBusted bool |
| 20 | 20 |
} |
| 21 | 21 |
|
| 22 |
-func newImageProber(cacheBuilder builder.ImageCacheBuilder, cacheFrom []string, noCache bool) ImageProber {
|
|
| 22 |
+func newImageProber(cacheBuilder builder.ImageCacheBuilder, cacheFrom []string, platform string, noCache bool) ImageProber {
|
|
| 23 | 23 |
if noCache {
|
| 24 | 24 |
return &nopProber{}
|
| 25 | 25 |
} |
| 26 | 26 |
|
| 27 | 27 |
reset := func() builder.ImageCache {
|
| 28 |
- return cacheBuilder.MakeImageCache(cacheFrom) |
|
| 28 |
+ return cacheBuilder.MakeImageCache(cacheFrom, platform) |
|
| 29 | 29 |
} |
| 30 | 30 |
return &imageProber{cache: reset(), reset: reset}
|
| 31 | 31 |
} |
| ... | ... |
@@ -18,7 +18,7 @@ type MockBackend struct {
|
| 18 | 18 |
containerCreateFunc func(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error) |
| 19 | 19 |
commitFunc func(string, *backend.ContainerCommitConfig) (string, error) |
| 20 | 20 |
getImageFunc func(string) (builder.Image, builder.ReleaseableLayer, error) |
| 21 |
- makeImageCacheFunc func(cacheFrom []string) builder.ImageCache |
|
| 21 |
+ makeImageCacheFunc func(cacheFrom []string, platform string) builder.ImageCache |
|
| 22 | 22 |
} |
| 23 | 23 |
|
| 24 | 24 |
func (m *MockBackend) ContainerAttachRaw(cID string, stdin io.ReadCloser, stdout, stderr io.Writer, stream bool, attached chan struct{}) error {
|
| ... | ... |
@@ -71,9 +71,9 @@ func (m *MockBackend) GetImageAndReleasableLayer(ctx context.Context, refOrID st |
| 71 | 71 |
return &mockImage{id: "theid"}, &mockLayer{}, nil
|
| 72 | 72 |
} |
| 73 | 73 |
|
| 74 |
-func (m *MockBackend) MakeImageCache(cacheFrom []string) builder.ImageCache {
|
|
| 74 |
+func (m *MockBackend) MakeImageCache(cacheFrom []string, platform string) builder.ImageCache {
|
|
| 75 | 75 |
if m.makeImageCacheFunc != nil {
|
| 76 |
- return m.makeImageCacheFunc(cacheFrom) |
|
| 76 |
+ return m.makeImageCacheFunc(cacheFrom, platform) |
|
| 77 | 77 |
} |
| 78 | 78 |
return nil |
| 79 | 79 |
} |
| ... | ... |
@@ -1,22 +1,18 @@ |
| 1 | 1 |
package daemon |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "runtime" |
|
| 5 |
- |
|
| 6 | 4 |
"github.com/Sirupsen/logrus" |
| 7 | 5 |
"github.com/docker/docker/builder" |
| 8 | 6 |
"github.com/docker/docker/image/cache" |
| 9 | 7 |
) |
| 10 | 8 |
|
| 11 | 9 |
// MakeImageCache creates a stateful image cache. |
| 12 |
-func (daemon *Daemon) MakeImageCache(sourceRefs []string) builder.ImageCache {
|
|
| 10 |
+func (daemon *Daemon) MakeImageCache(sourceRefs []string, platform string) builder.ImageCache {
|
|
| 13 | 11 |
if len(sourceRefs) == 0 {
|
| 14 |
- // TODO @jhowardmsft LCOW. For now, assume it is the OS of the host |
|
| 15 |
- return cache.NewLocal(daemon.stores[runtime.GOOS].imageStore) |
|
| 12 |
+ return cache.NewLocal(daemon.stores[platform].imageStore) |
|
| 16 | 13 |
} |
| 17 | 14 |
|
| 18 |
- // TODO @jhowardmsft LCOW. For now, assume it is the OS of the host |
|
| 19 |
- cache := cache.New(daemon.stores[runtime.GOOS].imageStore) |
|
| 15 |
+ cache := cache.New(daemon.stores[platform].imageStore) |
|
| 20 | 16 |
|
| 21 | 17 |
for _, ref := range sourceRefs {
|
| 22 | 18 |
img, err := daemon.GetImage(ref) |