2016-09-22 17:38:00 -04:00
|
|
|
package daemon
|
|
|
|
|
|
|
|
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.
|
2017-08-24 14:48:16 -04:00
|
|
|
func (daemon *Daemon) MakeImageCache(sourceRefs []string) builder.ImageCache {
|
2016-09-22 17:38:00 -04:00
|
|
|
if len(sourceRefs) == 0 {
|
2017-08-24 14:48:16 -04:00
|
|
|
return cache.NewLocal(daemon.imageStore)
|
2016-09-22 17:38:00 -04:00
|
|
|
}
|
|
|
|
|
2017-08-24 14:48:16 -04: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
|
|
|
|
}
|