-
Notifications
You must be signed in to change notification settings - Fork 19
/
groot.go
89 lines (72 loc) · 1.97 KB
/
groot.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package groot // import "code.cloudfoundry.org/grootfs/groot"
import (
"net/url"
"os"
"code.cloudfoundry.org/lager"
specsv1 "github.com/opencontainers/image-spec/specs-go/v1"
)
const GLOBAL_LOCK_KEY = "global-groot-lock"
//go:generate counterfeiter . Bundler
//go:generate counterfeiter . ImagePuller
//go:generate counterfeiter . Locksmith
//go:generate counterfeiter . DependencyManager
//go:generate counterfeiter . GarbageCollector
//go:generate counterfeiter . StoreMeasurer
type IDMappingSpec struct {
HostID int
NamespaceID int
Size int
}
type ImageSpec struct {
DiskLimit int64
ExcludeImageFromQuota bool
ImageSrc *url.URL
UIDMappings []IDMappingSpec
GIDMappings []IDMappingSpec
}
type Image struct {
VolumePath string
Image specsv1.Image
ChainIDs []string
}
type ImagePuller interface {
Pull(logger lager.Logger, spec ImageSpec) (Image, error)
}
type BundleSpec struct {
ID string
DiskLimit int64
ExcludeImageFromQuota bool
VolumePath string
Image specsv1.Image
}
type Bundle struct {
Path string
RootFSPath string
}
type Bundler interface {
Exists(id string) (bool, error)
Create(logger lager.Logger, spec BundleSpec) (Bundle, error)
Destroy(logger lager.Logger, id string) error
Metrics(logger lager.Logger, id string) (VolumeMetrics, error)
}
type DependencyManager interface {
Register(id string, chainIDs []string) error
Deregister(id string) error
}
type GarbageCollector interface {
Collect(logger lager.Logger, keepImages []string) error
}
type StoreMeasurer interface {
MeasureStore(logger lager.Logger) (uint64, error)
}
type Locksmith interface {
Lock(key string) (*os.File, error)
Unlock(lockFile *os.File) error
}
type DiskUsage struct {
TotalBytesUsed int64 `json:"total_bytes_used"`
ExclusiveBytesUsed int64 `json:"exclusive_bytes_used"`
}
type VolumeMetrics struct {
DiskUsage DiskUsage `json:"disk_usage"`
}