commit
cb0d51cca3
|
@ -1,27 +0,0 @@
|
||||||
package cache
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"errors"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GCPolicy defines policy for garbage collection
|
|
||||||
type GCPolicy struct {
|
|
||||||
MaxSize uint64
|
|
||||||
MaxKeepDuration time.Duration
|
|
||||||
}
|
|
||||||
|
|
||||||
// // CachePolicy defines policy for keeping a resource in cache
|
|
||||||
// type CachePolicy struct {
|
|
||||||
// Priority int
|
|
||||||
// LastUsed time.Time
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func defaultCachePolicy() CachePolicy {
|
|
||||||
// return CachePolicy{Priority: 10, LastUsed: time.Now()}
|
|
||||||
// }
|
|
||||||
|
|
||||||
func (cm *cacheManager) GC(ctx context.Context) error {
|
|
||||||
return errors.New("GC not implemented")
|
|
||||||
}
|
|
|
@ -25,7 +25,6 @@ var (
|
||||||
|
|
||||||
type ManagerOpt struct {
|
type ManagerOpt struct {
|
||||||
Snapshotter snapshot.SnapshotterBase
|
Snapshotter snapshot.SnapshotterBase
|
||||||
GCPolicy GCPolicy
|
|
||||||
MetadataStore *metadata.Store
|
MetadataStore *metadata.Store
|
||||||
PruneRefChecker ExternalRefCheckerFunc
|
PruneRefChecker ExternalRefCheckerFunc
|
||||||
}
|
}
|
||||||
|
@ -40,7 +39,6 @@ type Accessor interface {
|
||||||
type Controller interface {
|
type Controller interface {
|
||||||
DiskUsage(ctx context.Context, info client.DiskUsageInfo) ([]*client.UsageInfo, error)
|
DiskUsage(ctx context.Context, info client.DiskUsageInfo) ([]*client.UsageInfo, error)
|
||||||
Prune(ctx context.Context, ch chan client.UsageInfo, info ...client.PruneInfo) error
|
Prune(ctx context.Context, ch chan client.UsageInfo, info ...client.PruneInfo) error
|
||||||
GC(ctx context.Context) error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Manager interface {
|
type Manager interface {
|
||||||
|
|
|
@ -7,12 +7,14 @@ import (
|
||||||
digest "github.com/opencontainers/go-digest"
|
digest "github.com/opencontainers/go-digest"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// WithMetaResolver adds a metadata resolver to an image
|
||||||
func WithMetaResolver(mr ImageMetaResolver) ImageOption {
|
func WithMetaResolver(mr ImageMetaResolver) ImageOption {
|
||||||
return imageOptionFunc(func(ii *ImageInfo) {
|
return imageOptionFunc(func(ii *ImageInfo) {
|
||||||
ii.metaResolver = mr
|
ii.metaResolver = mr
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ImageMetaResolver can resolve image config metadata from a reference
|
||||||
type ImageMetaResolver interface {
|
type ImageMetaResolver interface {
|
||||||
ResolveImageConfig(ctx context.Context, ref string, opt gw.ResolveImageConfigOpt) (digest.Digest, []byte, error)
|
ResolveImageConfig(ctx context.Context, ref string, opt gw.ResolveImageConfigOpt) (digest.Digest, []byte, error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// WorkerInfo contains information about a worker
|
||||||
type WorkerInfo struct {
|
type WorkerInfo struct {
|
||||||
ID string
|
ID string
|
||||||
Labels map[string]string
|
Labels map[string]string
|
||||||
|
@ -18,6 +19,7 @@ type WorkerInfo struct {
|
||||||
GCPolicy []PruneInfo
|
GCPolicy []PruneInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListWorkers lists all active workers
|
||||||
func (c *Client) ListWorkers(ctx context.Context, opts ...ListWorkersOption) ([]*WorkerInfo, error) {
|
func (c *Client) ListWorkers(ctx context.Context, opts ...ListWorkersOption) ([]*WorkerInfo, error) {
|
||||||
info := &ListWorkersInfo{}
|
info := &ListWorkersInfo{}
|
||||||
for _, o := range opts {
|
for _, o := range opts {
|
||||||
|
@ -44,10 +46,12 @@ func (c *Client) ListWorkers(ctx context.Context, opts ...ListWorkersOption) ([]
|
||||||
return wi, nil
|
return wi, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListWorkersOption is an option for a worker list query
|
||||||
type ListWorkersOption interface {
|
type ListWorkersOption interface {
|
||||||
SetListWorkersOption(*ListWorkersInfo)
|
SetListWorkersOption(*ListWorkersInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListWorkersInfo is a payload for worker list query
|
||||||
type ListWorkersInfo struct {
|
type ListWorkersInfo struct {
|
||||||
Filter []string
|
Filter []string
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ type containerdExecutor struct {
|
||||||
cgroupParent string
|
cgroupParent string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// New creates a new executor backed by connection to containerd API
|
||||||
func New(client *containerd.Client, root, cgroup string, networkProviders map[pb.NetMode]network.Provider) executor.Executor {
|
func New(client *containerd.Client, root, cgroup string, networkProviders map[pb.NetMode]network.Provider) executor.Executor {
|
||||||
return containerdExecutor{
|
return containerdExecutor{
|
||||||
client: client,
|
client: client,
|
||||||
|
|
|
@ -29,6 +29,7 @@ type HealthConfig struct {
|
||||||
Retries int `json:",omitempty"`
|
Retries int `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ImageConfig is a docker compatible config for an image
|
||||||
type ImageConfig struct {
|
type ImageConfig struct {
|
||||||
specs.ImageConfig
|
specs.ImageConfig
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"google.golang.org/grpc/metadata"
|
"google.golang.org/grpc/metadata"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Hijack hijacks session to a connection.
|
||||||
func Hijack(stream controlapi.Control_SessionServer) (net.Conn, <-chan struct{}, map[string][]string) {
|
func Hijack(stream controlapi.Control_SessionServer) (net.Conn, <-chan struct{}, map[string][]string) {
|
||||||
md, _ := metadata.FromIncomingContext(stream.Context())
|
md, _ := metadata.FromIncomingContext(stream.Context())
|
||||||
c, closeCh := streamToConn(stream)
|
c, closeCh := streamToConn(stream)
|
||||||
|
|
|
@ -18,11 +18,13 @@ import (
|
||||||
"google.golang.org/grpc/metadata"
|
"google.golang.org/grpc/metadata"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// AgentConfig is the config for a single exposed SSH agent
|
||||||
type AgentConfig struct {
|
type AgentConfig struct {
|
||||||
ID string
|
ID string
|
||||||
Paths []string
|
Paths []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewSSHAgentProvider creates a session provider that allows access to ssh agent
|
||||||
func NewSSHAgentProvider(confs []AgentConfig) (session.Attachable, error) {
|
func NewSSHAgentProvider(confs []AgentConfig) (session.Attachable, error) {
|
||||||
m := map[string]source{}
|
m := map[string]source{}
|
||||||
for _, conf := range confs {
|
for _, conf := range confs {
|
||||||
|
|
|
@ -10,12 +10,12 @@ import (
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CacheID string
|
// NewInMemoryCacheManager creates a new in-memory cache manager
|
||||||
|
|
||||||
func NewInMemoryCacheManager() CacheManager {
|
func NewInMemoryCacheManager() CacheManager {
|
||||||
return NewCacheManager(identity.NewID(), NewInMemoryCacheStorage(), NewInMemoryResultStorage())
|
return NewCacheManager(identity.NewID(), NewInMemoryCacheStorage(), NewInMemoryResultStorage())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewCacheManager creates a new cache manager with specific storage backend
|
||||||
func NewCacheManager(id string, storage CacheKeyStorage, results CacheResultStorage) CacheManager {
|
func NewCacheManager(id string, storage CacheKeyStorage, results CacheResultStorage) CacheManager {
|
||||||
cm := &cacheManager{
|
cm := &cacheManager{
|
||||||
id: id,
|
id: id,
|
||||||
|
|
|
@ -26,7 +26,7 @@ type Builder interface {
|
||||||
|
|
||||||
// Solver provides a shared graph of all the vertexes currently being
|
// Solver provides a shared graph of all the vertexes currently being
|
||||||
// processed. Every vertex that is being solved needs to be loaded into job
|
// processed. Every vertex that is being solved needs to be loaded into job
|
||||||
// first. Vertex operations are invoked and progress tracking happends through
|
// first. Vertex operations are invoked and progress tracking happens through
|
||||||
// jobs.
|
// jobs.
|
||||||
type Solver struct {
|
type Solver struct {
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
|
|
|
@ -1,12 +1,25 @@
|
||||||
package pb
|
package pb
|
||||||
|
|
||||||
|
// InputIndex is incrementing index to the input vertex
|
||||||
type InputIndex int64
|
type InputIndex int64
|
||||||
|
|
||||||
|
// OutputIndex is incrementing index that another vertex can depend on
|
||||||
type OutputIndex int64
|
type OutputIndex int64
|
||||||
|
|
||||||
|
// RootMount is a base mountpoint
|
||||||
const RootMount = "/"
|
const RootMount = "/"
|
||||||
|
|
||||||
|
// SkipOutput marks a disabled output index
|
||||||
const SkipOutput OutputIndex = -1
|
const SkipOutput OutputIndex = -1
|
||||||
|
|
||||||
|
// Empty marks an input with no content
|
||||||
const Empty InputIndex = -1
|
const Empty InputIndex = -1
|
||||||
|
|
||||||
|
// LLBBuilder is a special builder for BuildOp that directly builds LLB
|
||||||
const LLBBuilder InputIndex = -1
|
const LLBBuilder InputIndex = -1
|
||||||
|
|
||||||
|
// LLBDefinitionInput marks an input that contains LLB definition for BuildOp
|
||||||
const LLBDefinitionInput = "buildkit.llb.definition"
|
const LLBDefinitionInput = "buildkit.llb.definition"
|
||||||
|
|
||||||
|
// LLBDefaultDefinitionFile is a filename containing the definition in LLBBuilder
|
||||||
const LLBDefaultDefinitionFile = LLBDefinitionInput
|
const LLBDefaultDefinitionFile = LLBDefinitionInput
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// NewMultiProvider creates a new mutable provider with a base provider
|
||||||
func NewMultiProvider(base content.Provider) *MultiProvider {
|
func NewMultiProvider(base content.Provider) *MultiProvider {
|
||||||
return &MultiProvider{
|
return &MultiProvider{
|
||||||
base: base,
|
base: base,
|
||||||
|
@ -18,12 +19,14 @@ func NewMultiProvider(base content.Provider) *MultiProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MultiProvider is a provider backed by a mutable map of providers
|
||||||
type MultiProvider struct {
|
type MultiProvider struct {
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
base content.Provider
|
base content.Provider
|
||||||
sub map[digest.Digest]content.Provider
|
sub map[digest.Digest]content.Provider
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReaderAt returns a content.ReaderAt
|
||||||
func (mp *MultiProvider) ReaderAt(ctx context.Context, desc ocispec.Descriptor) (content.ReaderAt, error) {
|
func (mp *MultiProvider) ReaderAt(ctx context.Context, desc ocispec.Descriptor) (content.ReaderAt, error) {
|
||||||
mp.mu.RLock()
|
mp.mu.RLock()
|
||||||
if p, ok := mp.sub[desc.Digest]; ok {
|
if p, ok := mp.sub[desc.Digest]; ok {
|
||||||
|
@ -37,6 +40,7 @@ func (mp *MultiProvider) ReaderAt(ctx context.Context, desc ocispec.Descriptor)
|
||||||
return mp.base.ReaderAt(ctx, desc)
|
return mp.base.ReaderAt(ctx, desc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add adds a new child provider for a specific digest
|
||||||
func (mp *MultiProvider) Add(dgst digest.Digest, p content.Provider) {
|
func (mp *MultiProvider) Add(dgst digest.Digest, p content.Provider) {
|
||||||
mp.mu.Lock()
|
mp.mu.Lock()
|
||||||
defer mp.mu.Unlock()
|
defer mp.mu.Unlock()
|
||||||
|
|
|
@ -18,7 +18,7 @@ import (
|
||||||
// DockerExporter implements containerd/images.Exporter to
|
// DockerExporter implements containerd/images.Exporter to
|
||||||
// Docker Combined Image JSON + Filesystem Changeset Format v1.1
|
// Docker Combined Image JSON + Filesystem Changeset Format v1.1
|
||||||
// https://github.com/moby/moby/blob/master/image/spec/v1.1.md#combined-image-json--filesystem-changeset-format
|
// https://github.com/moby/moby/blob/master/image/spec/v1.1.md#combined-image-json--filesystem-changeset-format
|
||||||
// The outputed tarball is also compatible wih OCI Image Format Specification
|
// The output tarball is also compatible with OCI Image Format Specification
|
||||||
type DockerExporter struct {
|
type DockerExporter struct {
|
||||||
Name string
|
Name string
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,11 +21,13 @@ type contextKeyT string
|
||||||
|
|
||||||
var contextKey = contextKeyT("buildkit/util/flightcontrol.progress")
|
var contextKey = contextKeyT("buildkit/util/flightcontrol.progress")
|
||||||
|
|
||||||
|
// Group is a flightcontrol syncronization group
|
||||||
type Group struct {
|
type Group struct {
|
||||||
mu sync.Mutex // protects m
|
mu sync.Mutex // protects m
|
||||||
m map[string]*call // lazily initialized
|
m map[string]*call // lazily initialized
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do executes a context function syncronized by the key
|
||||||
func (g *Group) Do(ctx context.Context, key string, fn func(ctx context.Context) (interface{}, error)) (v interface{}, err error) {
|
func (g *Group) Do(ctx context.Context, key string, fn func(ctx context.Context) (interface{}, error)) (v interface{}, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if errors.Cause(err) == errRetry {
|
if errors.Cause(err) == errRetry {
|
||||||
|
@ -312,13 +314,3 @@ func (ps *progressState) close(pw progress.Writer) {
|
||||||
}
|
}
|
||||||
ps.mu.Unlock()
|
ps.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func WriteProgress(ctx context.Context, pw progress.Writer) error {
|
|
||||||
v := ctx.Value(contextKey)
|
|
||||||
p, ok := v.(*progressState)
|
|
||||||
if !ok {
|
|
||||||
return errors.Errorf("invalid context not from flightcontrol")
|
|
||||||
}
|
|
||||||
p.add(pw)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ func (p *Puller) Pull(ctx context.Context) (*Pulled, error) {
|
||||||
childrenHandler := images.ChildrenHandler(p.ContentStore)
|
childrenHandler := images.ChildrenHandler(p.ContentStore)
|
||||||
// Set any children labels for that content
|
// Set any children labels for that content
|
||||||
childrenHandler = images.SetChildrenLabels(p.ContentStore, childrenHandler)
|
childrenHandler = images.SetChildrenLabels(p.ContentStore, childrenHandler)
|
||||||
// Filter the childen by the platform
|
// Filter the children by the platform
|
||||||
childrenHandler = images.FilterPlatforms(childrenHandler, platform)
|
childrenHandler = images.FilterPlatforms(childrenHandler, platform)
|
||||||
// Limit manifests pulled to the best match in an index
|
// Limit manifests pulled to the best match in an index
|
||||||
childrenHandler = images.LimitManifests(childrenHandler, platform, 1)
|
childrenHandler = images.LimitManifests(childrenHandler, platform, 1)
|
||||||
|
|
Loading…
Reference in New Issue