github.com/Cloud-Foundations/Dominator@v0.3.4/lib/image/api.go (about) 1 package image 2 3 import ( 4 "time" 5 6 "github.com/Cloud-Foundations/Dominator/lib/filesystem" 7 "github.com/Cloud-Foundations/Dominator/lib/filter" 8 "github.com/Cloud-Foundations/Dominator/lib/hash" 9 "github.com/Cloud-Foundations/Dominator/lib/log" 10 "github.com/Cloud-Foundations/Dominator/lib/objectserver" 11 "github.com/Cloud-Foundations/Dominator/lib/tags" 12 "github.com/Cloud-Foundations/Dominator/lib/triggers" 13 ) 14 15 type Annotation struct { 16 Object *hash.Hash // These are mutually exclusive. 17 URL string 18 } 19 20 type DirectoryMetadata struct { 21 OwnerGroup string 22 } 23 24 type Directory struct { 25 Name string 26 Metadata DirectoryMetadata 27 } 28 29 type Image struct { 30 BuildBranch string 31 BuildCommitId string 32 BuildGitUrl string 33 CreatedBy string // Username. Set by imageserver. Empty: unauthenticated 34 CreatedFor string // Username. Set by imaginator. 35 Filter *filter.Filter 36 FileSystem *filesystem.FileSystem 37 Triggers *triggers.Triggers 38 ReleaseNotes *Annotation 39 BuildLog *Annotation 40 CreatedOn time.Time 41 ExpiresAt time.Time 42 Packages []Package 43 SourceImage string // Name of source image. 44 Tags tags.Tags 45 } 46 47 type Package struct { 48 Name string 49 Size uint64 // Bytes. 50 Version string 51 } 52 53 // ForEachObject will call objectFunc for all objects (including those for 54 // annotations) for the image. If objectFunc returns a non-nil error, processing 55 // stops and the error is returned. 56 func (image *Image) ForEachObject(objectFunc func(hash.Hash) error) error { 57 return image.forEachObject(objectFunc) 58 } 59 60 // GetMissingObjects will check if objectServer has all the objects for the 61 // image and if any are missing it will download them from objectsGetter and add 62 // them to objectServer. 63 func (image *Image) GetMissingObjects(objectServer objectserver.ObjectServer, 64 objectsGetter objectserver.ObjectsGetter, logger log.DebugLogger) error { 65 return image.getMissingObjects(objectServer, objectsGetter, logger) 66 } 67 68 func (image *Image) ListMissingObjects( 69 objectsChecker objectserver.ObjectsChecker) ([]hash.Hash, error) { 70 return image.listMissingObjects(objectsChecker) 71 } 72 73 // ListObjects will return a list of all objects (including those for 74 // annotations for an image). 75 func (image *Image) ListObjects() []hash.Hash { 76 return image.listObjects() 77 } 78 79 func (image *Image) RegisterStrings(registerFunc func(string)) { 80 image.registerStrings(registerFunc) 81 } 82 83 func (image *Image) ReplaceStrings(replaceFunc func(string) string) { 84 image.replaceStrings(replaceFunc) 85 } 86 87 // Verify will perform some self-consistency checks on the image. If a problem 88 // is found, an error is returned. 89 func (image *Image) Verify() error { 90 return image.verify() 91 } 92 93 func (image *Image) VerifyObjects(checker objectserver.ObjectsChecker) error { 94 return image.verifyObjects(checker) 95 } 96 97 // VerifyRequiredPaths will verify if required paths are present in the image. 98 // The table of required paths is given by requiredPaths. If the image is a 99 // sparse image (has no filter), then this check is skipped. If a problem is 100 // found, an error is returned. 101 // This function will create cache data associated with the image, consuming 102 // more memory. 103 func (image *Image) VerifyRequiredPaths(requiredPaths map[string]rune) error { 104 return image.verifyRequiredPaths(requiredPaths) 105 } 106 107 func SortDirectories(directories []Directory) { 108 sortDirectories(directories) 109 }