2016-09-22 21:38:00 +00:00
|
|
|
package daemon
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/Sirupsen/logrus"
|
|
|
|
"github.com/docker/docker/builder"
|
2017-01-03 18:19:27 +00:00
|
|
|
"github.com/docker/docker/image/cache"
|
2016-09-22 21:38:00 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// MakeImageCache creates a stateful image cache.
|
|
|
|
func (daemon *Daemon) MakeImageCache(sourceRefs []string) builder.ImageCache {
|
|
|
|
if len(sourceRefs) == 0 {
|
2017-01-03 18:19:27 +00:00
|
|
|
return cache.NewLocal(daemon.imageStore)
|
2016-09-22 21:38:00 +00:00
|
|
|
}
|
|
|
|
|
2017-01-03 18:19:27 +00:00
|
|
|
cache := cache.New(daemon.imageStore)
|
2016-09-22 21:38:00 +00:00
|
|
|
|
|
|
|
for _, ref := range sourceRefs {
|
|
|
|
img, err := daemon.GetImage(ref)
|
|
|
|
if err != nil {
|
|
|
|
logrus.Warnf("Could not look up %s for cache resolution, skipping: %+v", ref, err)
|
|
|
|
continue
|
|
|
|
}
|
2017-01-03 18:19:27 +00:00
|
|
|
cache.Populate(img)
|
2016-09-22 21:38:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return cache
|
|
|
|
}
|