2016-09-22 17:38:00 -04:00
|
|
|
package daemon
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/Sirupsen/logrus"
|
|
|
|
"github.com/docker/docker/builder"
|
2017-01-03 13:19:27 -05:00
|
|
|
"github.com/docker/docker/image/cache"
|
2016-09-22 17:38:00 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// MakeImageCache creates a stateful image cache.
|
|
|
|
func (daemon *Daemon) MakeImageCache(sourceRefs []string) builder.ImageCache {
|
|
|
|
if len(sourceRefs) == 0 {
|
2017-01-03 13:19:27 -05:00
|
|
|
return cache.NewLocal(daemon.imageStore)
|
2016-09-22 17:38:00 -04:00
|
|
|
}
|
|
|
|
|
2017-01-03 13:19:27 -05:00
|
|
|
cache := cache.New(daemon.imageStore)
|
2016-09-22 17:38:00 -04: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 13:19:27 -05:00
|
|
|
cache.Populate(img)
|
2016-09-22 17:38:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return cache
|
|
|
|
}
|