mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
779a5b3029
Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
31 lines
767 B
Go
31 lines
767 B
Go
package images // import "github.com/docker/docker/daemon/images"
|
|
|
|
import (
|
|
"context"
|
|
|
|
imagetypes "github.com/docker/docker/api/types/image"
|
|
"github.com/docker/docker/builder"
|
|
"github.com/docker/docker/image/cache"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// MakeImageCache creates a stateful image cache.
|
|
func (i *ImageService) MakeImageCache(sourceRefs []string) builder.ImageCache {
|
|
ctx := context.TODO()
|
|
if len(sourceRefs) == 0 {
|
|
return cache.NewLocal(i.imageStore)
|
|
}
|
|
|
|
cache := cache.New(i.imageStore)
|
|
|
|
for _, ref := range sourceRefs {
|
|
img, err := i.GetImage(ctx, ref, imagetypes.GetImageOpts{})
|
|
if err != nil {
|
|
logrus.Warnf("Could not look up %s for cache resolution, skipping: %+v", ref, err)
|
|
continue
|
|
}
|
|
cache.Populate(img)
|
|
}
|
|
|
|
return cache
|
|
}
|