Documentation
¶
Overview ¶
Package states manages the resolution and execution states of Earthfile targets, maintaining caches, tracking imports, and coordinating solvers.
Index ¶
- type CacheImports
- type CacheMount
- type DockerTarImageSolver
- type ImageDef
- type ImageResult
- type ImageSolverResults
- type InteractiveSession
- type InteractiveSessionKind
- type MultiImageSolver
- type MultiTarget
- type RunPush
- type SaveImage
- type SaveLocal
- type SingleTarget
- func (sts *SingleTarget) AddBuildArgInput(bai dedup.BuildArgInput)
- func (sts *SingleTarget) AddDependentIDs(dependentIDs map[string]bool)
- func (sts *SingleTarget) AddWaitBlock(waitBlock WaitBlock)
- func (sts *SingleTarget) AttachTopLevelWaitItems(_ context.Context, waitBlock WaitBlock)
- func (sts *SingleTarget) Done() chan struct{}
- func (sts *SingleTarget) GetDoPushes() bool
- func (sts *SingleTarget) GetDoSaves() bool
- func (sts *SingleTarget) LastSaveImage() SaveImage
- func (sts *SingleTarget) MonitorDependencySubscription(ctx context.Context, inCh chan string)
- func (sts *SingleTarget) NewDependencySubscription() chan string
- func (sts *SingleTarget) SetDoPushes()
- func (sts *SingleTarget) SetDoSaves()
- func (sts *SingleTarget) TargetInput() dedup.TargetInput
- func (sts *SingleTarget) Wait(ctx context.Context) error
- type SolveCache
- type StateKey
- type VisitedCollection
- type WaitBlock
- type WaitItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheImports ¶
type CacheImports struct {
// contains filtered or unexported fields
}
CacheImports is a synchronized set of cache imports.
func NewCacheImports ¶
func NewCacheImports(imports []string) *CacheImports
NewCacheImports creates a new cache imports structure.
func (*CacheImports) AsSlice ¶
func (ci *CacheImports) AsSlice() []string
AsSlice returns the cache imports contents as a slice.
func (*CacheImports) Has ¶
func (ci *CacheImports) Has(tag string) bool
Has checks if a passed tag is added.
type CacheMount ¶
type CacheMount struct {
// RunOption Run options
RunOption llb.RunOption
// Persisted should the cache be persisted to image.
Persisted bool
}
CacheMount holds run options needed to cache mounts, and some extra options.
type DockerTarImageSolver ¶
type DockerTarImageSolver interface {
SolveImage(ctx context.Context, mts *MultiTarget, dockerTag string, outFile string, printOutput bool) error
}
DockerTarImageSolver can create a Docker image and make it available as a tar file.
type ImageDef ¶
type ImageDef struct {
Platform platutil.Platform
MTS *MultiTarget
ImageName string
}
ImageDef includes the information required to build an image in BuildKit.
type ImageResult ¶
type ImageResult struct {
ImageDescriptor *ocispecs.Descriptor
Annotations map[string]string
IntermediateImageName string
FinalImageName string
FinalImageNameWithDigest string
ImageDigest string
ConfigDigest string
NewInterImgFormat bool
}
ImageResult contains data about an image that was built.
type ImageSolverResults ¶
type ImageSolverResults struct {
ResultChan chan *ImageResult
ErrChan chan error
ReleaseFunc func()
}
ImageSolverResults contains data and channels that allow one to act on images during and after they are built.
type InteractiveSession ¶
type InteractiveSession struct {
State pllb.State
CommandStr string
Kind InteractiveSessionKind
Initialized bool
}
InteractiveSession holds the relevant data for running an interactive session when it is not desired to save the resulting changes into an image.
type InteractiveSessionKind ¶
type InteractiveSessionKind string
InteractiveSessionKind represents what kind of interactive session has been encountered.
const ( // SessionKeep is a session where the data *persists* in the image when it exits. SessionKeep InteractiveSessionKind = "keep" // SessionEphemeral is a session where the data *does not persist* in the image when it exits. SessionEphemeral InteractiveSessionKind = "ephemeral" )
type MultiImageSolver ¶
type MultiImageSolver interface {
SolveImages(ctx context.Context, defs []*ImageDef) (*ImageSolverResults, error)
}
MultiImageSolver can create a Docker image for the WITH DOCKER command using the embedded BuildKit registry.
type MultiTarget ¶
type MultiTarget struct {
// Visited represents the previously visited states, grouped by target
// name. Duplicate targets are possible if same target is called with different
// build args.
Visited VisitedCollection
// Final is the main target to be built.
Final *SingleTarget
}
MultiTarget holds LLB states representing multiple earth targets, in the order in which they should be built.
func (*MultiTarget) All ¶
func (mts *MultiTarget) All() []*SingleTarget
All returns all SingleTarget contained within.
func (*MultiTarget) FinalTarget ¶
func (mts *MultiTarget) FinalTarget() domain.Target
FinalTarget returns the final target of the states.
type RunPush ¶
type RunPush struct {
State pllb.State
InteractiveSession InteractiveSession
CommandStrs []string
SaveLocals []SaveLocal
SaveImages []SaveImage
HasState bool
}
RunPush is a series of RUN --push commands to be run after the build has been deemed as successful, along with artifacts to save and images to push.
type SaveImage ¶
type SaveImage struct {
State pllb.State
Platform platutil.Platform
Image *image.Image
DockerTag string
HasPushDependencies bool
// CacheHint instructs earth to save a separate ref for this image, even if no tag is provided.
CacheHint bool
InsecurePush bool
// ForceSave indicates whether the image should be force-saved and (possibly pushed).
ForceSave bool
// CheckDuplicate indicates whether to check if the image name shows up
// multiple times during output.
CheckDuplicate bool
// NoManifestList indicates that the image should not include a manifest
// list (usually used for multi-platform setups). This means that the image
// can only be a single-platform image.
NoManifestList bool
Push bool
// true when the --platform value was set (either on cli, or via FROM --platform=..., or BUILD --platform=...)
HasPlatform bool
SkipBuilder bool // for use with WAIT/END
}
SaveImage is a docker image to be saved.
type SaveLocal ¶
type SaveLocal struct {
// DestPath is the local dest path to copy the artifact to.
DestPath string
// ArtifactPath is the relative path within the artifacts image.
ArtifactPath string
// Index is the index number of the "save as local" command encountered. Starts as 0.
Index int
// IfExists allows the artifact to be optional.
IfExists bool
}
SaveLocal is an artifact path to be saved to local disk.
type SingleTarget ¶
type SingleTarget struct {
MainState pllb.State
ArtifactsState pllb.State
Target domain.Target
SaveLocals []SaveLocal
SeparateArtifactsState []pllb.State
// WaitBlocks contains the caller's waitblock plus any additional waitblocks defined in the target
WaitBlocks []WaitBlock
// WaitItems contains all wait items which are created by the target
// it exists for tracking items in the target vs a caller's wait block that is shared between multiple targets
WaitItems []WaitItem
SaveImages []SaveImage
// ID is a random unique string.
ID string
GlobalImports map[string]domain.ImportTrackerVal
MainImage *image.Image
PlatformResolver *platutil.Resolver
VarCollection *variables.Collection
InteractiveSession InteractiveSession
RunPush RunPush
// HasDangling represents whether the target has dangling instructions -
// ie if there are any non-SAVE commands after the first SAVE command,
// or if the target is invoked via BUILD command (not COPY nor FROM).
HasDangling bool
// RanFromLike represents whether we have encountered a FROM-like command
// (eg FROM, FROM DOCKERFILE, LOCALLY).
RanFromLike bool
// RanInteractive represents whether we have encountered an --interactive command.
RanInteractive bool
// contains filtered or unexported fields
}
SingleTarget holds LLB states representing an earth target.
func (*SingleTarget) AddBuildArgInput ¶
func (sts *SingleTarget) AddBuildArgInput(bai dedup.BuildArgInput)
AddBuildArgInput adds a bai to the sts's target input.
func (*SingleTarget) AddDependentIDs ¶
func (sts *SingleTarget) AddDependentIDs(dependentIDs map[string]bool)
AddDependentIDs adds additional IDs that depend on this sts.
func (*SingleTarget) AddWaitBlock ¶
func (sts *SingleTarget) AddWaitBlock(waitBlock WaitBlock)
AddWaitBlock adds a wait block to the state.
func (*SingleTarget) AttachTopLevelWaitItems ¶
func (sts *SingleTarget) AttachTopLevelWaitItems(_ context.Context, waitBlock WaitBlock)
AttachTopLevelWaitItems adds pre-created wait items to a new waitblock.
func (*SingleTarget) Done ¶
func (sts *SingleTarget) Done() chan struct{}
Done returns a channel that is closed when the sts is complete.
func (*SingleTarget) GetDoPushes ¶
func (sts *SingleTarget) GetDoPushes() bool
GetDoPushes returns whether the SAVE IMAGE --push or RUN --push commands should be executed.
func (*SingleTarget) GetDoSaves ¶
func (sts *SingleTarget) GetDoSaves() bool
GetDoSaves returns whether the SaveImages and the SaveLocals should be actually saved.
func (*SingleTarget) LastSaveImage ¶
func (sts *SingleTarget) LastSaveImage() SaveImage
LastSaveImage returns the last save image available (if any).
func (*SingleTarget) MonitorDependencySubscription ¶
func (sts *SingleTarget) MonitorDependencySubscription(ctx context.Context, inCh chan string)
MonitorDependencySubscription monitors for new dependencies.
func (*SingleTarget) NewDependencySubscription ¶
func (sts *SingleTarget) NewDependencySubscription() chan string
NewDependencySubscription adds additional IDs that depend on this sts.
func (*SingleTarget) SetDoPushes ¶
func (sts *SingleTarget) SetDoPushes()
SetDoPushes sets the doPushes flag.
func (*SingleTarget) SetDoSaves ¶
func (sts *SingleTarget) SetDoSaves()
SetDoSaves sets the DoSaves flag.
func (*SingleTarget) TargetInput ¶
func (sts *SingleTarget) TargetInput() dedup.TargetInput
TargetInput returns the target input in a concurrent-safe way.
type SolveCache ¶
SolveCache is a formal version of the cache we keep mapping targets to their LLB state.
func NewSolveCache ¶
func NewSolveCache() *SolveCache
NewSolveCache gives a new SolveCache instance.
type StateKey ¶
type StateKey string
StateKey is a type for a key in SolveCache. These keys seem to be highly convention based, and used elsewhere too (LocalFolders?). so this is a step at formalizing that convention, since we sometimes need one key, and sometimes another. It may give us some toeholds to help with some refactoring later.
func KeyFromHashAndTag ¶
func KeyFromHashAndTag(target *SingleTarget, dockerTag string) (StateKey, error)
KeyFromHashAndTag builds a state key from a given target state and a docker tag. This is useful when you want to reference the same image but with a different name.
type VisitedCollection ¶
type VisitedCollection interface {
// All returns all visited items.
All() []*SingleTarget
// Add adds a target to the collection, if it hasn't yet been visited. The returned sts is
// either the previously visited one or a brand new one.
Add(
ctx context.Context,
target domain.Target,
platr *platutil.Resolver,
allowPrivileged bool,
overridingVars *variables.Scope,
parentDepSub chan string,
) (*SingleTarget, bool, error)
}
VisitedCollection represents a collection of visited targets.
func NewLegacyVisitedCollection ¶
func NewLegacyVisitedCollection() VisitedCollection
NewLegacyVisitedCollection returns a collection of visited targets.
func NewVisitedUpfrontHashCollection ¶
func NewVisitedUpfrontHashCollection() VisitedCollection
NewVisitedUpfrontHashCollection returns a collection of visited targets.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package dedup provides target and build arg deduplication for earth's build states, ensuring identical targets are not evaluated multiple times.
|
Package dedup provides target and build arg deduplication for earth's build states, ensuring identical targets are not evaluated multiple times. |
|
Package image provides data structures and logic for representing and manipulating container images within the build state.
|
Package image provides data structures and logic for representing and manipulating container images within the build state. |