2018-02-07 15:52:47 -05:00
|
|
|
package images // import "github.com/docker/docker/daemon/images"
|
2016-09-22 17:38:00 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/docker/docker/builder"
|
2017-01-03 13:19:27 -05:00
|
|
|
"github.com/docker/docker/image/cache"
|
2017-07-26 17:42:13 -04:00
|
|
|
"github.com/sirupsen/logrus"
|
2016-09-22 17:38:00 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// MakeImageCache creates a stateful image cache.
|
2018-02-07 15:52:47 -05:00
|
|
|
func (i *ImageService) MakeImageCache(sourceRefs []string) builder.ImageCache {
|
2016-09-22 17:38:00 -04:00
|
|
|
if len(sourceRefs) == 0 {
|
2018-02-02 17:18:46 -05:00
|
|
|
return cache.NewLocal(i.imageStore)
|
2016-09-22 17:38:00 -04:00
|
|
|
}
|
|
|
|
|
2018-02-02 17:18:46 -05:00
|
|
|
cache := cache.New(i.imageStore)
|
2016-09-22 17:38:00 -04:00
|
|
|
|
|
|
|
for _, ref := range sourceRefs {
|
2018-02-02 17:18:46 -05:00
|
|
|
img, err := i.GetImage(ref)
|
2016-09-22 17:38:00 -04:00
|
|
|
if err != nil {
|
|
|
|
logrus.Warnf("Could not look up %s for cache resolution, skipping: %+v", ref, err)
|
|
|
|
continue
|
|
|
|
}
|
2017-01-03 13:19:27 -05:00
|
|
|
cache.Populate(img)
|
2016-09-22 17:38:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return cache
|
|
|
|
}
|