frontend

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// KeyDefaultPlatform is the subreuqest id for returning the default platform
	// for the builder.
	KeyDefaultPlatform = "frontend.dalec.defaultPlatform"
)

Variables

This section is empty.

Functions

func BuildWithPlatform

func BuildWithPlatform(ctx context.Context, client gwclient.Client, f PlatformBuildFunc) (*gwclient.Result, error)

BuildWithPlatform is a helper function to build a spec with a given platform It takes care of looping through each target platform and executing the build with the platform args substituted in the spec. This also deals with the docker-style multi-platform output.

func BuildWithPlatformFromUIClient

func BuildWithPlatformFromUIClient(ctx context.Context, client gwclient.Client, dc *dockerui.Client, f PlatformBuildFunc) (*gwclient.Result, error)

Like BuildWithPlatform but with a pre-initialized dockerui.Client

func ForwarderFromClient

func ForwarderFromClient(ctx context.Context, client gwclient.Client) dalec.ForwarderFunc

ForwarderFromClient creates a dalec.ForwarderFunc from a gateway client. This is used for forwarding builds to other frontends in dalec.Source2LLBGetter

func GetBaseImage

func GetBaseImage(sOpt dalec.SourceOpts, ref string, opts ...llb.ConstraintsOpt) llb.State

GetBaseImage returns an image that first checks if the client provided the image in the build context matching the image ref.

This follows the behavior of of the dockerfile frontend.

func GetBuildArg

func GetBuildArg(client gwclient.Client, k string) (string, bool)

func GetCurrentFrontend

func GetCurrentFrontend(client gwclient.Client) (llb.State, error)

func GetTargetKey

func GetTargetKey(client BuildOpstGetter) string

GetTargetKey returns the key that should be used to select the dalec.Target from the dalec.Spec

func IgnoreCache

func IgnoreCache(client gwclient.Client, refs ...string) llb.ConstraintsOpt

Returns a ConstraintsOpt that ignores the cache if the client is configured to ignore the cache for any of the given refs OR if the global no-cache option is set.

func LoadBuiltinTargets

func LoadBuiltinTargets(targets map[string]gwclient.BuildFunc) func(context.Context, gwclient.Client, *BuildMux) error

LoadBuiltinTargets is like WithBuiltinHandler but accepts a mapping of handlers instead of one at a time.

func LoadSpec

func LoadSpec(ctx context.Context, client *dockerui.Client, platform *ocispecs.Platform, opts ...LoadOpt) (*dalec.Spec, error)

func MaybeSign

func MaybeSign(ctx context.Context, client gwclient.Client, st llb.State, spec *dalec.Spec, targetKey string, sOpt dalec.SourceOpts, opts ...llb.ConstraintsOpt) llb.State

func RunTests

func RunTests(ctx context.Context, client gwclient.Client, spec *dalec.Spec, ref gwclient.Reference, withTestDeps llb.StateOption, target string, platform *ocispecs.Platform) error

RunTests runs the tests defined in the spec against the given target container.

func SourceOptFromClient

func SourceOptFromClient(ctx context.Context, c gwclient.Client, platform *ocispecs.Platform) (dalec.SourceOpts, error)

func SourceOptFromUIClient

func SourceOptFromUIClient(ctx context.Context, c gwclient.Client, dc *dockerui.Client, platform *ocispecs.Platform) dalec.SourceOpts

func SupportsDiffMerge

func SupportsDiffMerge(client gwclient.Client) bool

SupportsDiffMerge checks if the given client supports the diff and merge operations.

func Warn

func Warn(ctx context.Context, client gwclient.Client, st llb.State, msg string)

Warn sends a warning to the client for the provided state.

func Warnf

func Warnf(ctx context.Context, client gwclient.Client, st llb.State, format string, args ...any)

func WithBuiltinHandler

func WithBuiltinHandler(key string, bf gwclient.BuildFunc) func(context.Context, gwclient.Client, *BuildMux) error

WithBuiltinHandler registers a late-binding handler for the given target key. These are only added if the target is in the spec OR the spec has no explicit targets.

func WithDefaultPlatform

func WithDefaultPlatform(platform ocispecs.Platform, build gwclient.BuildFunc) gwclient.BuildFunc

WithDefaultPlatform is a helper function to set a default platform for a build if the client does not provide one.

func WithTargetForwardingHandler

func WithTargetForwardingHandler(ctx context.Context, client gwclient.Client, m *BuildMux) error

WithTargetForwardingHandler registers a handler for each spec target that has a custom frontend

Types

type BuildMux

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

BuildMux route handlers also must be buildkit BuildFuncs. As such a handler can itself also be a distinc BuildMux with its own set of routes. This allows handlers to also do their own routing. All logic for what to route is handled outside of the BuildMux.

BuildMux and buildkit BuildFunc have a similar relationship as http.ServeMux and http.Handler (where http.ServeMux is an http.Handler). In the same way BuildMux is a BuildFunc (or rather BuildMux.Handle is). So BuildMux can be nested.

When BuildMux calls a handler, it modifies the client to chomp off the matched route prefix. So a BuildMux with receiving a build target of mariner2/container will match on the registered handler for mariner2 then call the handler with the build target changed to just container.

Finally, BuildMux sets an extra build option on the client dalec.target=<matched prefix>. This is only done if the dalec.target option is not already set, so dalec.target is only modified once and then used in handlers to determine which target in spec.Targets applies to them.

func (*BuildMux) Add

func (m *BuildMux) Add(targetPath string, bf gwclient.BuildFunc, info *bktargets.Target)

Add adds a handler for the given target [targetPath] is the resource path to be handled

func (*BuildMux) Handle

func (m *BuildMux) Handle(ctx context.Context, client gwclient.Client) (_ *gwclient.Result, retErr error)

Handle is a gwclient.BuildFunc that routes requests to registered handlers

func (*BuildMux) Handler

func (m *BuildMux) Handler(opts ...func(context.Context, gwclient.Client, *BuildMux) error) gwclient.BuildFunc

Handler returns a gwclient.BuildFunc that uses the mux to route requests to appropriate handlers

type BuildOpstGetter

type BuildOpstGetter interface {
	BuildOpts() gwclient.BuildOpts
}

type CurrentFrontend

type CurrentFrontend interface {
	CurrentFrontend() (*llb.State, error)
}

CurrentFrontend is an interface typically implemented by a gwclient.Client This is used to get the rootfs of the current frontend.

type LoadConfig

type LoadConfig struct {
	SubstituteOpts []dalec.SubstituteOpt
}

type LoadOpt

type LoadOpt func(*LoadConfig)

func WithAllowArgs

func WithAllowArgs(args ...string) LoadOpt

type PlatformBuildFunc

type PlatformBuildFunc func(ctx context.Context, client gwclient.Client, platform *ocispecs.Platform, spec *dalec.Spec, targetKey string) (gwclient.Reference, *dalec.DockerImageSpec, error)

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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