states

package
v0.7.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2023 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheImports added in v0.6.15

type CacheImports struct {
	// contains filtered or unexported fields
}

CacheImports is a synchronized set of cache imports.

func NewCacheImports added in v0.6.15

func NewCacheImports(imports []string) *CacheImports

NewCacheImports creates a new cache imports structure.

func (*CacheImports) Add added in v0.6.15

func (ci *CacheImports) Add(tag string)

Add adds import to the set.

func (*CacheImports) AsSlice added in v0.6.22

func (ci *CacheImports) AsSlice() []string

AsSlice returns the cache imports contents as a slice.

func (*CacheImports) Has added in v0.6.22

func (ci *CacheImports) Has(tag string) bool

Has checks if a passed tag is added.

type DockerTarImageSolver added in v0.6.15

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 added in v0.6.15

type ImageDef struct {
	MTS       *MultiTarget
	ImageName string
	Platform  platutil.Platform
}

ImageDef includes the information required to build an image in BuildKit.

type ImageResult added in v0.6.20

type ImageResult struct {
	IntermediateImageName    string
	FinalImageName           string
	FinalImageNameWithDigest string
	ImageDigest              string
	ConfigDigest             string
	ImageDescriptor          *ocispecs.Descriptor
	Annotations              map[string]string
	NewInterImgFormat        bool
}

ImageResult contains data about an image that was built.

type ImageSolverResults added in v0.6.15

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 added in v0.6.15

type InteractiveSession struct {
	CommandStr  string
	State       pllb.State
	Initialized bool
	Kind        InteractiveSessionKind
}

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 added in v0.6.15

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 added in v0.6.15

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 earthly 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 {
	CommandStrs        []string
	State              pllb.State
	SaveLocals         []SaveLocal
	SaveImages         []SaveImage
	InteractiveSession InteractiveSession
	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
	Image        *image.Image
	DockerTag    string
	Push         bool
	InsecurePush bool
	// CacheHint instructs Earthly to save a separate ref for this image, even if no tag is
	// provided.
	CacheHint           bool
	HasPushDependencies 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

	Platform    platutil.Platform
	HasPlatform bool // true when the --platform value was set (either on cli, or via FROM --platform=..., or BUILD --platform=...)

	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 {
	// ID is a random unique string.
	ID                     string
	Target                 domain.Target
	PlatformResolver       *platutil.Resolver
	MainImage              *image.Image
	MainState              pllb.State
	ArtifactsState         pllb.State
	SeparateArtifactsState []pllb.State
	SaveLocals             []SaveLocal
	SaveImages             []SaveImage
	VarCollection          *variables.Collection
	RunPush                RunPush
	InteractiveSession     InteractiveSession
	GlobalImports          map[string]domain.ImportTrackerVal
	// 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

	// WaitBlocks contains the caller's waitblock plus any additional waitblocks defined in the target
	WaitBlocks []waitutil.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 []waitutil.WaitItem
	// contains filtered or unexported fields
}

SingleTarget holds LLB states representing an earthly target.

func (*SingleTarget) AddBuildArgInput added in v0.6.15

func (sts *SingleTarget) AddBuildArgInput(bai dedup.BuildArgInput)

AddBuildArgInput adds a bai to the sts's target input.

func (*SingleTarget) AddDependentIDs added in v0.6.15

func (sts *SingleTarget) AddDependentIDs(dependentIDs map[string]bool)

AddDependentIDs adds additional IDs that depend on this sts.

func (*SingleTarget) AddWaitBlock added in v0.7.0

func (sts *SingleTarget) AddWaitBlock(waitBlock waitutil.WaitBlock)

AddWaitBlock adds a wait block to the state

func (*SingleTarget) AttachTopLevelWaitItems added in v0.7.0

func (sts *SingleTarget) AttachTopLevelWaitItems(ctx context.Context, waitBlock waitutil.WaitBlock)

AttachTopLevelWaitItems adds pre-created wait items to a new waitblock

func (*SingleTarget) Done added in v0.6.15

func (sts *SingleTarget) Done() chan struct{}

Done returns a channel that is closed when the sts is complete.

func (*SingleTarget) GetDoPushes added in v0.6.20

func (sts *SingleTarget) GetDoPushes() bool

GetDoPushes returns whether the SAVE IMAGE --push or RUN --push commands should be executed

func (*SingleTarget) GetDoSaves added in v0.6.15

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 added in v0.6.15

func (sts *SingleTarget) MonitorDependencySubscription(ctx context.Context, inCh chan string)

MonitorDependencySubscription monitors for new dependencies.

func (*SingleTarget) NewDependencySubscription added in v0.6.15

func (sts *SingleTarget) NewDependencySubscription() chan string

NewDependencySubscription adds additional IDs that depend on this sts.

func (*SingleTarget) SetDoPushes added in v0.6.20

func (sts *SingleTarget) SetDoPushes()

SetDoPushes sets the doPushes flag.

func (*SingleTarget) SetDoSaves added in v0.6.15

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.

func (*SingleTarget) Wait added in v0.7.0

func (sts *SingleTarget) Wait(ctx context.Context) error

Wait performs a Wait on all wait blocks

type SolveCache added in v0.4.4

type SolveCache struct {
	// contains filtered or unexported fields
}

SolveCache is a formal version of the cache we keep mapping targets to their LLB state.

func NewSolveCache added in v0.4.4

func NewSolveCache() *SolveCache

NewSolveCache gives a new SolveCachemap instance

func (*SolveCache) Do added in v0.6.15

func (sc *SolveCache) Do(ctx context.Context, sk StateKey, constructor SolveCacheConstructor) (pllb.State, error)

Do sets an LLB state in the given solve cache. If the state has been previously constructed, it is returned immediately without calling the constructor again.

type SolveCacheConstructor added in v0.6.15

type SolveCacheConstructor func(context.Context, StateKey) (pllb.State, error)

SolveCacheConstructor is func taking a StateKey and returning a state.

type StateKey added in v0.4.4

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 added in v0.4.4

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.

func KeyFromState added in v0.4.4

func KeyFromState(target *SingleTarget) (StateKey, error)

KeyFromState is a simple wrapper to get a key from a given state using the hash of its target.

type VisitedCollection added in v0.3.12

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 added in v0.7.21

func NewLegacyVisitedCollection() VisitedCollection

NewLegacyVisitedCollection returns a collection of visited targets.

func NewVisitedUpfrontHashCollection added in v0.7.21

func NewVisitedUpfrontHashCollection() VisitedCollection

NewVisitedUpfrontHashCollection returns a collection of visited targets.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL