Documentation ¶
Overview ¶
Package lib implements some of the core computations in the dominator.
Package lib provides functions for computing differences between a sub and desired image to generate lists of objects for fetching and pushing and update requests. It contains some common code that both the dominator and the push-image subcommand of subtool share.
Index ¶
- Variables
- func BuildMissingLists(sub Sub, image *image.Image, pushComputedFiles bool, ...) (map[hash.Hash]uint64, map[hash.Hash]struct{})
- func BuildUpdateRequest(sub Sub, image *image.Image, request *subproto.UpdateRequest, ...) bool
- func PushObjects(sub Sub, objectsToPush map[hash.Hash]struct{}, logger log.Logger) error
- type Sub
Constants ¶
This section is empty.
Variables ¶
var (
ErrorFailedToGetObject = errors.New("get object failed")
)
Functions ¶
func BuildMissingLists ¶
func BuildMissingLists(sub Sub, image *image.Image, pushComputedFiles bool, ignoreMissingComputedFiles bool, logger log.Logger) ( map[hash.Hash]uint64, map[hash.Hash]struct{})
BuildMissingLists will construct lists of objects to be fetched by the sub from an object server and the list of computed objects that should be pushed to the sub. The lists are generated by comparing the contents of sub.FileSystem and sub.ObjectCache with the desired image. If pushComputedFiles is true then the list of computed files to be pushed is generated. If ignoreMissingComputedFiles is true then missing computed files are ignored, otherwise these missing files lead to an error and early termination of the function. Computed file metadata are specified by sub.ComputedInodes. BuildMissingLists returns a slice of objects to fetch and a map of files to push. The map is nil if there are missing computed files.
func BuildUpdateRequest ¶
func BuildUpdateRequest(sub Sub, image *image.Image, request *subproto.UpdateRequest, deleteMissingComputedFiles bool, ignoreMissingComputedFiles bool, logger log.Logger) bool
BuildUpdateRequest will build an update request which can be sent to the sub. If deleteMissingComputedFiles is true then missing computed files are deleted on the sub, else missing computed files lead to the function failing. If deleteMissingComputedFiles is false and ignoreMissingComputedFiles is true then missing computed files are ignored. It returns true if the function failed due to missing computed files.
Types ¶
type Sub ¶
type Sub struct { Hostname string Client *srpc.Client FileSystem *filesystem.FileSystem ComputedInodes map[string]*filesystem.RegularInode ObjectCache objectcache.ObjectCache ObjectGetter objectserver.ObjectGetter // contains filtered or unexported fields }
Sub should be initialised with data to be used in the package functions.