forked from vmware-archive/atc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cache.go
33 lines (24 loc) · 751 Bytes
/
cache.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package resource
import "github.com/concourse/atc/worker"
const initializedProperty = "initialized"
type noopCache struct{}
func (noopCache) IsInitialized() (bool, error) { return false, nil }
func (noopCache) Initialize() error { return nil }
func (noopCache) Volume() worker.Volume { return nil }
type volumeCache struct {
volume worker.Volume
}
func (cache volumeCache) IsInitialized() (bool, error) {
props, err := cache.volume.Properties()
if err != nil {
return false, err
}
_, found := props[initializedProperty]
return found, nil
}
func (cache volumeCache) Initialize() error {
return cache.volume.SetProperty("initialized", "yep")
}
func (cache volumeCache) Volume() worker.Volume {
return cache.volume
}