Documentation ¶
Index ¶
Constants ¶
const AlreadyPresentInSetErrorMessage = "resource with given path already present in set"
AlreadyPresentInSetErrorMessage is the message returned for AlreadyPresentInSetError errors
Variables ¶
This section is empty.
Functions ¶
func IsAlreadyPresentInSetError ¶
IsAlreadyPresentInSetError checks if error e is of the type AlreadyPresentInSetError
Types ¶
type AlreadyPresentInSetError ¶
type AlreadyPresentInSetError error
AlreadyPresentInSetError is returned on an unsuccessful call to Add()
type Artifactory ¶
type Artifactory interface { // Reset zeros out any data structures that store resource information // in memory. It also deletes the corresponding files from the host // filesystem Reset() error // ResetHandle zeros out the files and data from one given handle ResetHandle(handle string) error // AddResource gives an Artifactory a list of resource paths, for a // given handle, that may be requested by the user. Nominally, this // allows the artifactory to populate the data structure without // actually retrieving (and returning) the files from a container. // // I'm not 100% this function will be necessary. AddResource(handle string, resourcePaths ...string) error // EachResource will return an io.ReadCloser from which the // file contents can be read for each resource. The file contents // for each will be a tarball (compressed?) such that it can be // passed directly into the docker `archive` package's // DecompressSteam or Untar function. The intent is that the // resource be untarred / decompressed into // `$CONTEXT_DIR/$PREFIX/$RESOURCE_PATH` where $CONTEXT_DIR is the // directory from which the dependent image will be built, $PREFIX // is an arbitrary prefix (e.g. "inbox"), and $RESOURCE_PATH is the // full path at which the resource can be found *inside* the // container EachResource(handle string, resourceFunc func(*Resource, error) error) error }
Artifactory is a type that can be used to handle all of the artifact-related interactions for a given build. It is the responsibility of the caller to write the resulting artifacts to the correct place on disk once they are returned
func NewArtifactory ¶
func NewArtifactory(storageDir string) Artifactory
NewArtifactory produces an initialized instance of a struct that implements the Artifactory interface
type NewResourceOptions ¶
type NewResourceOptions struct { StorageDir string Handle string Path string // contains filtered or unexported fields }
NewResourceOptions is a struct to disambiguate the options passed to NewResource. Handle should be a valid containerID to ensure that artifact extraction is possible. If being used for testing, Handle may be nil, and resource.present should be set to true.
type RWArtifactory ¶
type RWArtifactory struct {
// contains filtered or unexported fields
}
RWArtifactory is an implementation of the Artifactory interface
func (*RWArtifactory) AddResource ¶
func (art *RWArtifactory) AddResource(h string, resourcePaths ...string) error
AddResource gives an Artifactory a list of resource paths, for a given handle, that may be requested by the user. Nominally, this allows the artifactory to populate the data structure without actually retrieving (and returning) the files from a container.
func (*RWArtifactory) EachResource ¶
EachResource will return an io.ReadCloser from which the file contents can be read for each resource. The file contents for each will be a tarball (compressed?) such that it can be passed directly into the docker `archive` package's DecompressSteam or Untar function. The intent is that the resource be untarred / decompressed into `$CONTEXT_DIR/$PREFIX/$RESOURCE_PATH` where $CONTEXT_DIR is the directory from which the dependent image will be built, $PREFIX is an arbitrary prefix (e.g. "inbox"), and $RESOURCE_PATH is the full path at which the resource can be found *inside* the container
func (*RWArtifactory) Reset ¶
func (art *RWArtifactory) Reset() error
Reset zeros out any data structures that store resource information in memory. It also deletes the corresponding files from the host filesystem
func (*RWArtifactory) ResetHandle ¶
func (art *RWArtifactory) ResetHandle(h string) error
ResetHandle zeros out the files and data from one given handle
type Resource ¶
type Resource struct { Error error // contains filtered or unexported fields }
Resource is a type that represents a filepath inside the container that corresponds to a real file on disk on the host machine. It has a nested read-write lock such that it may be locked when being concurrently read from / written to.
func NewResource ¶
func NewResource(opts NewResourceOptions) *Resource
NewResource returns a properly initialized resource
func (*Resource) ArtifactBytes ¶
ArtifactBytes returns the bytes of the artifact (a `.tar` archive)
type ResourceSet ¶
type ResourceSet struct {
// contains filtered or unexported fields
}
ResourceSet is a thread-safe hash map of resource values. Resources may be added and their artifacts will be available upon request
func NewResourceSet ¶
func NewResourceSet() *ResourceSet
NewResourceSet creates a fully initialized ResourceSet
func (*ResourceSet) Add ¶
func (set *ResourceSet) Add(r *Resource) error
Add adds resource r to the set. If a resource is already present with the same path (r.Path), Add will return an IsIsPresentInSetError
func (*ResourceSet) Each ¶
func (set *ResourceSet) Each(resourceFunc func(r *Resource, error error) error) error
Each iterates over each resource in the set in a threadsafe manner, yielding each one to function resourceFunc. If resourceFunc returns an error, that error is passed to the subseqwuent invocation.
func (*ResourceSet) Get ¶
func (set *ResourceSet) Get(path string) *Resource
Get returns the resource that exists at path (or nil)