NewProvider create a new CacheProvider based in the provided directory
(dir string)
| 24 | |
| 25 | // NewProvider create a new CacheProvider based in the provided directory |
| 26 | func NewProvider(dir string) (*Provider, error) { |
| 27 | p := &Provider{dir: dir, lockMut: sync.Mutex{}} |
| 28 | layout, err := p.Get(dir) |
| 29 | if err != nil { |
| 30 | return nil, err |
| 31 | } |
| 32 | store, err := local.NewStore(dir) |
| 33 | if err != nil { |
| 34 | return nil, err |
| 35 | } |
| 36 | p.cache = layout |
| 37 | p.store = store |
| 38 | return p, nil |
| 39 | } |
| 40 | |
| 41 | // Index returns the root image index for the cache. |
| 42 | // All attempts to read the index *must* use this function, so that it will lock the cache to prevent concurrent access. |