Documentation ¶
Index ¶
- Variables
- type Builder
- type CacheExportMode
- type CacheExportOpt
- type CacheExporter
- type CacheExporterRecord
- type CacheExporterTarget
- type CacheInfoLink
- type CacheKey
- type CacheKeyStorage
- type CacheKeyWithSelector
- type CacheLink
- type CacheManager
- type CacheMap
- type CacheRecord
- type CacheResult
- type CacheResultStorage
- type CachedResult
- type Edge
- type ExportableCacheKey
- type Index
- type Job
- func (j *Job) Build(ctx context.Context, e Edge) (CachedResult, error)
- func (j *Job) Context(ctx context.Context) context.Context
- func (j *Job) Discard() error
- func (j *Job) EachValue(ctx context.Context, key string, fn func(interface{}) error) error
- func (j *Job) SetValue(key string, v interface{})
- func (j *Job) Status(ctx context.Context, ch chan *client.SolveStatus) error
- type LoadedResult
- type Op
- type Remote
- type ResolveOpFunc
- type Result
- type ResultBasedCacheFunc
- type SharedCachedResult
- type SharedResult
- type Solver
- type SolverOpt
- type Vertex
- type VertexOptions
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.Errorf("not found")
Functions ¶
This section is empty.
Types ¶
type CacheExportMode ¶
type CacheExportMode int
CacheExportMode is the type for setting cache exporting modes
const ( // CacheExportModeMin exports a topmost allowed vertex and its dependencies // that already have transferable layers CacheExportModeMin CacheExportMode = iota // CacheExportModeMax exports all possible non-root vertexes CacheExportModeMax // CacheExportModeRemoteOnly only exports vertexes that already have // transferable layers CacheExportModeRemoteOnly )
type CacheExportOpt ¶
type CacheExportOpt struct { // Convert can convert a build result to transferable object Convert func(context.Context, Result) (*Remote, error) // Mode defines a cache export algorithm Mode CacheExportMode }
CacheExportOpt defines options for exporting build cache
type CacheExporter ¶
type CacheExporter interface {
ExportTo(ctx context.Context, t CacheExporterTarget, opt CacheExportOpt) ([]CacheExporterRecord, error)
}
CacheExporter can export the artifacts of the build chain
type CacheExporterRecord ¶
type CacheExporterRecord interface { AddResult(createdAt time.Time, result *Remote) LinkFrom(src CacheExporterRecord, index int, selector string) }
CacheExporterRecord is a single object being exported
type CacheExporterTarget ¶
type CacheExporterTarget interface { Add(dgst digest.Digest) CacheExporterRecord Visit(interface{}) Visited(interface{}) bool }
CacheExporterTarget defines object capable of receiving exports
type CacheInfoLink ¶
type CacheInfoLink struct { Input Index `json:"Input,omitempty"` Output Index `json:"Output,omitempty"` Digest digest.Digest `json:"Digest,omitempty"` Selector digest.Digest `json:"Selector,omitempty"` }
CacheInfoLink is a link between two cache keys
type CacheKey ¶
type CacheKey struct { ID string // contains filtered or unexported fields }
func NewCacheKey ¶
NewCacheKey creates a new cache key for a specific output index
func (*CacheKey) Deps ¶
func (ck *CacheKey) Deps() [][]CacheKeyWithSelector
type CacheKeyStorage ¶
type CacheKeyStorage interface { Exists(id string) bool Walk(fn func(id string) error) error WalkResults(id string, fn func(CacheResult) error) error Load(id string, resultID string) (CacheResult, error) AddResult(id string, res CacheResult) error Release(resultID string) error WalkIDsByResult(resultID string, fn func(string) error) error AddLink(id string, link CacheInfoLink, target string) error WalkLinks(id string, link CacheInfoLink, fn func(id string) error) error HasLink(id string, link CacheInfoLink, target string) bool WalkBacklinks(id string, fn func(id string, link CacheInfoLink) error) error }
CacheKeyStorage is interface for persisting cache metadata
func NewInMemoryCacheStorage ¶
func NewInMemoryCacheStorage() CacheKeyStorage
type CacheKeyWithSelector ¶
type CacheKeyWithSelector struct { Selector digest.Digest CacheKey ExportableCacheKey }
CacheKeyWithSelector combines a cache key with an optional selector digest. Used to limit the matches for dependency cache key.
type CacheLink ¶
type CacheLink struct { Source digest.Digest `json:",omitempty"` Input Index `json:",omitempty"` Output Index `json:",omitempty"` Base digest.Digest `json:",omitempty"` Selector digest.Digest `json:",omitempty"` }
CacheLink is a link between two cache records
type CacheManager ¶
type CacheManager interface { // ID is used to identify cache providers that are backed by same source // to avoid duplicate calls to the same provider ID() string // Query searches for cache paths from one cache key to the output of a // possible match. Query(inp []CacheKeyWithSelector, inputIndex Index, dgst digest.Digest, outputIndex Index) ([]*CacheKey, error) Records(ck *CacheKey) ([]*CacheRecord, error) // Load pulls and returns the cached result Load(ctx context.Context, rec *CacheRecord) (Result, error) // Save saves a result based on a cache key Save(key *CacheKey, s Result, createdAt time.Time) (*ExportableCacheKey, error) }
CacheManager implements build cache backend
func NewCacheManager ¶
func NewCacheManager(id string, storage CacheKeyStorage, results CacheResultStorage) CacheManager
NewCacheManager creates a new cache manager with specific storage backend
func NewInMemoryCacheManager ¶
func NewInMemoryCacheManager() CacheManager
NewInMemoryCacheManager creates a new in-memory cache manager
type CacheMap ¶
type CacheMap struct { // Digest is a base digest for operation that needs to be combined with // inputs cache or selectors for dependencies. Digest digest.Digest Deps []struct { // Optional digest that is merged with the cache key of the input Selector digest.Digest // Optional function that returns a digest for the input based on its // return value ComputeDigestFunc ResultBasedCacheFunc } }
type CacheRecord ¶
type CacheRecord struct { ID string Size int CreatedAt time.Time Priority int // contains filtered or unexported fields }
CacheRecord is an identifier for loading in cache
type CacheResult ¶
CacheResult is a record for a single solve result
type CacheResultStorage ¶
type CacheResultStorage interface { Save(Result, time.Time) (CacheResult, error) Load(ctx context.Context, res CacheResult) (Result, error) LoadRemote(ctx context.Context, res CacheResult) (*Remote, error) Exists(id string) bool }
CacheResultStorage is interface for converting cache metadata result to actual solve result
func NewInMemoryResultStorage ¶
func NewInMemoryResultStorage() CacheResultStorage
type CachedResult ¶
type CachedResult interface { Result CacheKeys() []ExportableCacheKey }
CachedResult is a result connected with its cache key
func NewCachedResult ¶
func NewCachedResult(res Result, k []ExportableCacheKey) CachedResult
NewCachedResult combines a result and cache key into cached result
type ExportableCacheKey ¶
type ExportableCacheKey struct { *CacheKey Exporter CacheExporter }
ExportableCacheKey is a cache key connected with an exporter that can export a chain of cacherecords pointing to that key
type Job ¶
type Job struct { SessionID string // contains filtered or unexported fields }
type LoadedResult ¶ added in v0.4.0
type LoadedResult struct { Result Result CacheResult CacheResult CacheKey *CacheKey }
type Op ¶
type Op interface { // CacheMap returns structure describing how the operation is cached. // Currently only roots are allowed to return multiple cache maps per op. CacheMap(context.Context, int) (*CacheMap, bool, error) // Exec runs an operation given results from previous operations. Exec(ctx context.Context, inputs []Result) (outputs []Result, err error) }
Op is an implementation for running a vertex
type Remote ¶
type Remote struct { Descriptors []ocispec.Descriptor Provider content.Provider }
Remote is a descriptor or a list of stacked descriptors that can be pulled from a content provider TODO: add closer to keep referenced data from getting deleted
type ResolveOpFunc ¶
ResolveOpFunc finds an Op implementation for a Vertex
type ResultBasedCacheFunc ¶
type SharedCachedResult ¶
type SharedCachedResult struct {}
func NewSharedCachedResult ¶
func NewSharedCachedResult(res CachedResult) *SharedCachedResult
func (*SharedCachedResult) Clone ¶
func (r *SharedCachedResult) Clone() CachedResult
type SharedResult ¶
type SharedResult struct {
// contains filtered or unexported fields
}
SharedResult is a result that can be cloned
func NewSharedResult ¶
func NewSharedResult(main Result) *SharedResult
func (*SharedResult) Clone ¶
func (r *SharedResult) Clone() Result
type Solver ¶
type Solver struct {
// contains filtered or unexported fields
}
Solver provides a shared graph of all the vertexes currently being processed. Every vertex that is being solved needs to be loaded into job first. Vertex operations are invoked and progress tracking happens through jobs.
type SolverOpt ¶
type SolverOpt struct { ResolveOpFunc ResolveOpFunc DefaultCache CacheManager }
type Vertex ¶
type Vertex interface { // Digest is a content-addressable vertex identifier Digest() digest.Digest // Sys returns an internal value that is used to execute the vertex. Usually // this is capured by the operation resolver method during solve. Sys() interface{} Options() VertexOptions // Array of edges current vertex depends on. Inputs() []Edge Name() string }
Vertex is one node in the build graph
type VertexOptions ¶
type VertexOptions struct { IgnoreCache bool CacheSources []CacheManager Description map[string]string // text values with no special meaning for solver ExportCache *bool }
VertexOptions has optional metadata for the vertex that is not contained in digest