buildcontext

package
v0.8.12 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: MPL-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTPProtocol = iota + 1
	HTTPSProtocol
	SSHProtocol
	GitProtocol
	UnknownProtocol
)

TODO eventually we should use gitutil.parseURL directly; but for now we want to avoid this change to keep this commit smaller

View Source
const DockerfileMetaTarget = "@dockerfile:"

DockerfileMetaTarget is a target name prefix which signals the resolver that the build file is a dockerfile. The DockerfileMetaTarget is really not a valid Earthly target otherwise.

Variables

View Source
var ErrNoMatch = errors.Errorf("no git match found")

ErrNoMatch occurs when no git matcher is found

View Source
var ImplicitExcludes = []string{
	".tmp-earthly-out/",
	"build.earth",
	"Earthfile",
	earthIgnoreFile,
	earthlyIgnoreFile,
}

ImplicitExcludes is a list of implicit patterns to exclude.

Functions

This section is empty.

Types

type Data

type Data struct {
	// The parsed Earthfile AST.
	Earthfile spec.Earthfile
	// EarthlyOrgName is the org that the target belongs to.
	EarthlyOrgName string
	// EarthlyProjectName is the project that the target belongs to.
	EarthlyProjectName string
	// BuildFilePath is the local path where the Earthfile or Dockerfile can be found.
	BuildFilePath string
	// BuildContext is the state to use for the build.
	BuildContextFactory llbfactory.Factory
	// GitMetadata contains git metadata information.
	GitMetadata *gitutil.GitMetadata
	// Target is the earthly reference.
	Ref domain.Reference
	// LocalDirs is the local dirs map to be passed as part of the buildkit solve.
	LocalDirs map[string]string
	// Features holds the feature state for the build context
	Features *features.Features
}

Data represents a resolved target's build context data.

type ErrEarthfileNotExist added in v0.6.26

type ErrEarthfileNotExist struct {
	Target string
}

ErrNotExist is the struct indicating that file does not exist.

func (ErrEarthfileNotExist) Error added in v0.6.26

func (err ErrEarthfileNotExist) Error() string

Error is function required by error interface.

type GitLookup added in v0.4.0

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

GitLookup looksup gits

func NewGitLookup added in v0.4.0

func NewGitLookup(console conslogging.ConsoleLogger, sshAuthSock string) *GitLookup

NewGitLookup creates new lookuper

func (*GitLookup) AddMatcher added in v0.4.0

func (gl *GitLookup) AddMatcher(name, pattern, sub, user, password, prefix, suffix, protocol, knownHosts string, strictHostKeyChecking bool, port int, sshCommand string) error

AddMatcher adds a new matcher for looking up git repos

func (*GitLookup) ConvertCloneURL added in v0.6.15

func (gl *GitLookup) ConvertCloneURL(inURL string) (gitURL string, keyScans []string, sshCommand string, err error)

ConvertCloneURL takes a url such as https://github.com/user/repo.git or git@github.com:user/repo.git and makes use of configured git credentials and protocol preferences to convert it into the appropriate https or ssh protocol. it also returns a keyScan and sshCommand

func (*GitLookup) DisableSSH added in v0.4.0

func (gl *GitLookup) DisableSSH()

DisableSSH changes all git matchers from ssh to https

func (*GitLookup) GetCloneURL added in v0.4.0

func (gl *GitLookup) GetCloneURL(path string) (gitURL string, subPath string, keyScans []string, sshCommand string, err error)

GetCloneURL returns the repo to clone, and a path relative to the repo

"github.com/earthly/earthly"             ---> ("git@github.com/earthly/earthly.git", "")
"github.com/earthly/earthly/examples"    ---> ("git@github.com/earthly/earthly.git", "examples")
"github.com/earthly/earthly/examples/go" ---> ("git@github.com/earthly/earthly.git", "examples/go")

Additionally a ssh keyscan might be returned (or an empty string indicating none was configured) Also, a custom "git ssh command" may be returned. This is part of this function since the user may specify a command necessary to clone their repository successfully.

type Resolver

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

Resolver is a build context resolver.

func NewResolver

func NewResolver(cleanCollection *cleanup.Collection, gitLookup *GitLookup, console conslogging.ConsoleLogger, featureFlagOverrides, gitBranchOverride, gitLFSInclude string, gitLogLevel buildkitgitutil.GitLogLevel, gitImage string) *Resolver

NewResolver returns a new NewResolver.

func (*Resolver) ExpandWildcard added in v0.8.0

func (r *Resolver) ExpandWildcard(ctx context.Context, gwClient gwclient.Client, platr *platutil.Resolver, parentTarget, target domain.Target) ([]string, error)

ExpandWildcard will expand a wildcard BUILD target in a local path or remote Git repository. Local and remote targets are treated differently. For local targets, we need to join the two targets in order to derive the full relative path. This is then used when globbing for matches. The paths are then made relative to the parent target for resolution by the caller.

func (*Resolver) Resolve

func (r *Resolver) Resolve(ctx context.Context, gwClient gwclient.Client, platr *platutil.Resolver, ref domain.Reference) (*Data, error)

Resolve returns resolved context data for a given Earthly reference. If the reference is a target, then the context will include a build context and possibly additional local directories.

Directories

Path Synopsis
Package provider is heavily based on fsSyncProvider in github.com/moby/buildkit/session/filesync.
Package provider is heavily based on fsSyncProvider in github.com/moby/buildkit/session/filesync.

Jump to

Keyboard shortcuts

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