earthfile2llb

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2020 License: MPL-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseDebug

func ParseDebug(filename string) error

ParseDebug parses a earthfile and prints debug information about it.

Types

type Converter

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

Converter turns earth commands to buildkit LLB representation.

func NewConverter

func NewConverter(ctx context.Context, target domain.Target, resolver *buildcontext.Resolver, dockerBuilderFun DockerBuilderFun, cleanCollection *cleanup.Collection, bc *buildcontext.Data, visitedStates map[string][]*SingleTargetStates, varCollection *variables.Collection) (*Converter, error)

NewConverter constructs a new converter for a given earth target.

func (*Converter) Arg

func (c *Converter) Arg(ctx context.Context, argKey string, defaultArgValue string)

Arg applies the ARG command.

func (*Converter) Build

func (c *Converter) Build(ctx context.Context, fullTargetName string, buildArgs []string) (*MultiTargetStates, error)

Build applies the earth BUILD command.

func (*Converter) Cmd

func (c *Converter) Cmd(ctx context.Context, cmdArgs []string, isWithShell bool)

Cmd applies the CMD command.

func (*Converter) CopyArtifact

func (c *Converter) CopyArtifact(ctx context.Context, artifactName string, dest string, buildArgs []string, isDir bool) error

CopyArtifact applies the earth COPY artifact command.

func (*Converter) CopyClassical

func (c *Converter) CopyClassical(ctx context.Context, srcs []string, dest string, isDir bool)

CopyClassical applies the earth COPY command, with classical args.

func (*Converter) DockerLoad

func (c *Converter) DockerLoad(ctx context.Context, targetName string, dockerTag string, buildArgs []string) error

DockerLoad applies the DOCKER LOAD command.

func (*Converter) DockerPull

func (c *Converter) DockerPull(ctx context.Context, dockerTag string) error

DockerPull applies the DOCKER PULL command.

func (*Converter) Entrypoint

func (c *Converter) Entrypoint(ctx context.Context, entrypointArgs []string, isWithShell bool)

Entrypoint applies the ENTRYPOINT command.

func (*Converter) Env

func (c *Converter) Env(ctx context.Context, envKey string, envValue string)

Env applies the ENV command.

func (*Converter) Expose

func (c *Converter) Expose(ctx context.Context, ports []string)

Expose applies the EXPOSE command.

func (*Converter) FinalizeStates

func (c *Converter) FinalizeStates() *MultiTargetStates

FinalizeStates returns the LLB states.

func (*Converter) From

func (c *Converter) From(ctx context.Context, imageName string, buildArgs []string) error

From applies the earth FROM command.

func (*Converter) GitClone

func (c *Converter) GitClone(ctx context.Context, gitURL string, branch string, dest string) error

GitClone applies the GIT CLONE command.

func (*Converter) Healthcheck added in v0.2.0

func (c *Converter) Healthcheck(ctx context.Context, isNone bool, cmdArgs []string, interval time.Duration, timeout time.Duration, startPeriod time.Duration, retries int)

Healthcheck applies the HEALTHCHECK command.

func (*Converter) Label

func (c *Converter) Label(ctx context.Context, labels map[string]string)

Label applies the LABEL command.

func (*Converter) Run

func (c *Converter) Run(ctx context.Context, args []string, mounts []string, secretKeyValues []string, privileged bool, withEntrypoint bool, withDocker bool, isWithShell bool, pushFlag bool) error

Run applies the earth RUN command.

func (*Converter) SaveArtifact

func (c *Converter) SaveArtifact(ctx context.Context, saveFrom string, saveTo string, saveAsLocalTo string) error

SaveArtifact applies the earth SAVE ARTIFACT command.

func (*Converter) SaveImage

func (c *Converter) SaveImage(ctx context.Context, imageNames []string, pushImages bool)

SaveImage applies the earth SAVE IMAGE command.

func (*Converter) User

func (c *Converter) User(ctx context.Context, user string)

User applies the USER command.

func (*Converter) Volume

func (c *Converter) Volume(ctx context.Context, volumes []string)

Volume applies the VOLUME command.

func (*Converter) Workdir

func (c *Converter) Workdir(ctx context.Context, workdirPath string)

Workdir applies the WORKDIR command.

type DockerBuilderFun

type DockerBuilderFun = func(ctx context.Context, mts *MultiTargetStates, dockerTag string, outFile string) error

DockerBuilderFun is a function able to build a target into a docker tar file.

type MultiTargetStates

type MultiTargetStates struct {
	// VisitedStates represents the previously visited states, grouped by target
	// name. Duplicate targets are possible if same target is called with different
	// build args.
	VisitedStates map[string][]*SingleTargetStates
	// FinalStates is the main target to be built.
	FinalStates *SingleTargetStates
}

MultiTargetStates holds LLB states representing multiple earth targets, in the order in which they should be built.

func Earthfile2LLB

func Earthfile2LLB(ctx context.Context, target domain.Target, resolver *buildcontext.Resolver, dockerBuilderFun DockerBuilderFun, cleanCollection *cleanup.Collection, visitedStates map[string][]*SingleTargetStates, varCollection *variables.Collection) (mts *MultiTargetStates, err error)

Earthfile2LLB parses a earthfile and executes the statements for a given target.

func (*MultiTargetStates) AllStates

func (mts *MultiTargetStates) AllStates() []*SingleTargetStates

AllStates returns all SingleTargetStates contained within.

func (*MultiTargetStates) FinalTarget

func (mts *MultiTargetStates) FinalTarget() domain.Target

FinalTarget returns the final target of the states.

type RunPush

type RunPush struct {
	Initialized bool
	CommandStrs []string
	State       llb.State
}

RunPush is a series of RUN --push commands to be run after the build has been deemed as successful.

type SaveImage

type SaveImage struct {
	State     llb.State
	Image     *image.Image
	DockerTag string
	Push      bool
}

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
}

SaveLocal is an artifact path to be saved to local disk.

type SingleTargetStates

type SingleTargetStates struct {
	Target                 domain.Target
	TargetInput            dedup.TargetInput
	SideEffectsImage       *image.Image
	SideEffectsState       llb.State
	ArtifactsState         llb.State
	SeparateArtifactsState []llb.State
	SaveLocals             []SaveLocal
	SaveImages             []SaveImage
	RunPush                RunPush
	LocalDirs              map[string]string
	Ongoing                bool
}

SingleTargetStates holds LLB states representing a earth target.

func (*SingleTargetStates) LastSaveImage

func (sts *SingleTargetStates) LastSaveImage() (SaveImage, bool)

LastSaveImage returns the last save image available (if any).

type StringSliceFlag

type StringSliceFlag struct {
	Args []string
}

StringSliceFlag is a flag backed by a string slice.

func (*StringSliceFlag) Set

func (ssf *StringSliceFlag) Set(arg string) error

Set adds a flag value to the string slice.

func (*StringSliceFlag) String

func (ssf *StringSliceFlag) String() string

String returns a string representation of the flag.

Directories

Path Synopsis
Package imr is based on github.com/moby/buildkit/client/llb/imagemetaresolver, except that it applies a docker authorizer, which uses the standard docker credentials already available on the system.
Package imr is based on github.com/moby/buildkit/client/llb/imagemetaresolver, except that it applies a docker authorizer, which uses the standard docker credentials already available on the system.

Jump to

Keyboard shortcuts

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