-
Notifications
You must be signed in to change notification settings - Fork 6
/
api.go
109 lines (92 loc) · 3.29 KB
/
api.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package image
import (
"time"
"github.com/Cloud-Foundations/Dominator/lib/filesystem"
"github.com/Cloud-Foundations/Dominator/lib/filter"
"github.com/Cloud-Foundations/Dominator/lib/hash"
"github.com/Cloud-Foundations/Dominator/lib/log"
"github.com/Cloud-Foundations/Dominator/lib/objectserver"
"github.com/Cloud-Foundations/Dominator/lib/tags"
"github.com/Cloud-Foundations/Dominator/lib/triggers"
)
type Annotation struct {
Object *hash.Hash // These are mutually exclusive.
URL string
}
type DirectoryMetadata struct {
OwnerGroup string
}
type Directory struct {
Name string
Metadata DirectoryMetadata
}
type Image struct {
BuildBranch string
BuildCommitId string
BuildGitUrl string
CreatedBy string // Username. Set by imageserver. Empty: unauthenticated
CreatedFor string // Username. Set by imaginator.
Filter *filter.Filter
FileSystem *filesystem.FileSystem
Triggers *triggers.Triggers
ReleaseNotes *Annotation
BuildLog *Annotation
CreatedOn time.Time
ExpiresAt time.Time
Packages []Package
SourceImage string // Name of source image.
Tags tags.Tags
}
type Package struct {
Name string
Size uint64 // Bytes.
Version string
}
// ForEachObject will call objectFunc for all objects (including those for
// annotations) for the image. If objectFunc returns a non-nil error, processing
// stops and the error is returned.
func (image *Image) ForEachObject(objectFunc func(hash.Hash) error) error {
return image.forEachObject(objectFunc)
}
// GetMissingObjects will check if objectServer has all the objects for the
// image and if any are missing it will download them from objectsGetter and add
// them to objectServer.
func (image *Image) GetMissingObjects(objectServer objectserver.ObjectServer,
objectsGetter objectserver.ObjectsGetter, logger log.DebugLogger) error {
return image.getMissingObjects(objectServer, objectsGetter, logger)
}
func (image *Image) ListMissingObjects(
objectsChecker objectserver.ObjectsChecker) ([]hash.Hash, error) {
return image.listMissingObjects(objectsChecker)
}
// ListObjects will return a list of all objects (including those for
// annotations for an image).
func (image *Image) ListObjects() []hash.Hash {
return image.listObjects()
}
func (image *Image) RegisterStrings(registerFunc func(string)) {
image.registerStrings(registerFunc)
}
func (image *Image) ReplaceStrings(replaceFunc func(string) string) {
image.replaceStrings(replaceFunc)
}
// Verify will perform some self-consistency checks on the image. If a problem
// is found, an error is returned.
func (image *Image) Verify() error {
return image.verify()
}
func (image *Image) VerifyObjects(checker objectserver.ObjectsChecker) error {
return image.verifyObjects(checker)
}
// VerifyRequiredPaths will verify if required paths are present in the image.
// The table of required paths is given by requiredPaths. If the image is a
// sparse image (has no filter), then this check is skipped. If a problem is
// found, an error is returned.
// This function will create cache data associated with the image, consuming
// more memory.
func (image *Image) VerifyRequiredPaths(requiredPaths map[string]rune) error {
return image.verifyRequiredPaths(requiredPaths)
}
func SortDirectories(directories []Directory) {
sortDirectories(directories)
}