states

package
v0.6.18 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2022 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareTargetInputs added in v0.6.15

func CompareTargetInputs(target domain.Target, platr *platutil.Resolver, allowPrivileged bool, overridingVars *variables.Scope, other dedup.TargetInput) (bool, error)

CompareTargetInputs compares two targets and their inputs to check if they are the same.

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 map[string]bool) *CacheImports

NewCacheImports creates a new cache imports structure.

func (*CacheImports) Add added in v0.6.15

func (ci *CacheImports) Add(tag string)

Add adds an import to the set.

func (*CacheImports) AsMap added in v0.6.15

func (ci *CacheImports) AsMap() map[string]bool

AsMap returns the cache imports contents as a map.

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

type ImageSolverResults struct {
	ResultChan  chan string
	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=...)
}

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

func (sts *SingleTarget) AddOverridingVarsAsBuildArgInputs(overridingVars *variables.Scope)

AddOverridingVarsAsBuildArgInputs adds some vars to the sts's target input.

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

func (sts *SingleTarget) GetDoSaves() bool

GetDoSaves returns whether the SaveImages and the SaveLocals should be actually saved (and possibly pushed).

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) 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.

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 struct {
	// contains filtered or unexported fields
}

VisitedCollection is a collection of visited targets.

func NewVisitedCollection added in v0.3.12

func NewVisitedCollection() *VisitedCollection

NewVisitedCollection returns a collection of visited targets.

func (*VisitedCollection) Add added in v0.3.12

func (vc *VisitedCollection) Add(ctx context.Context, target domain.Target, platr *platutil.Resolver, allowPrivileged bool, overridingVars *variables.Scope, parentDepSub chan string) (*SingleTarget, bool, error)

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.

func (*VisitedCollection) All added in v0.6.15

func (vc *VisitedCollection) All() []*SingleTarget

All returns all visited items.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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