frontend

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// KeyDefaultPlatform is the subrequest id for returning the default platform
	// for the builder.
	KeyDefaultPlatform = "frontend.dalec.defaultPlatform"
	KeyJSONSchema      = "frontend.dalec.schema"
)
View Source
const IgnoreCacheTestsKey = "dalec.tests"

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

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 LoadSpec

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

func LoadSpecForRouting added in v0.21.0

func LoadSpecForRouting(ctx context.Context, client gwclient.Client) (*dalec.Spec, error)

LoadSpecForRouting loads a dalec spec from the gateway client's build context for routing purposes only. Build args are substituted with WithAllowAnyArg so that unresolved args don't cause errors during route setup.

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, sOpt dalec.SourceOpts, spec *dalec.Spec, withTestDeps llb.StateOption, target string, opts ...llb.ConstraintsOpt) llb.StateOption

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

func TestWithClientFrontend(client gwclient.Client) testrunner.ValidationOpt

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 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, r *Router) error

WithTargetForwardingHandler registers a forwarding handler for each spec target that has a custom frontend. This replaces any builtin routes for that target key prefix.

Types

type BuildOpstGetter

type BuildOpstGetter interface {
	BuildOpts() gwclient.BuildOpts
}

type Forward added in v0.21.0

type Forward struct {
	Spec     *dalec.Spec
	Frontend *dalec.Frontend
}

Forward holds the configuration needed to query a forwarded frontend's target list at list time.

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)

type Route added in v0.21.0

type Route struct {
	// FullPath is the fully qualified route path, e.g. "azlinux3/container".
	FullPath string

	// Handler is the build function that handles this route.
	Handler gwclient.BuildFunc

	// Info contains target metadata for the target list API.
	Info Target

	// Forward, if set, indicates this route forwards to an external frontend.
	// The target list queries the remote frontend lazily to discover sub-targets.
	Forward *Forward
}

Route is a single entry in the flat router.

type Router added in v0.21.0

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

Router is a flat route table where all routes are fully qualified paths. It replaces the hierarchical BuildMux with a simpler dispatch model.

func (*Router) Add added in v0.21.0

func (r *Router) Add(ctx context.Context, route Route)

Add registers a route. If a route with the same FullPath already exists it is overwritten (this is used by target forwarding to override builtins).

func (*Router) Handle added in v0.21.0

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

Handle is the main dispatch function. It handles subrequests, then looks up the target in the route table and calls the matched handler.

func (*Router) Handler added in v0.21.0

func (r *Router) Handler(opts ...func(context.Context, gwclient.Client, *Router) error) gwclient.BuildFunc

Handler returns a gwclient.BuildFunc that dispatches requests through the router. Option functions run once at the start of each request before dispatch.

type Target added in v0.21.0

type Target struct {
	bktargets.Target

	// SpecDefined indicates that the top-level target key for this route
	// appears in spec.Targets. When spec.Targets is empty (no explicit
	// target filtering), this field is false for all targets.
	SpecDefined bool `json:"specDefined,omitempty"`

	// Hidden indicates that this route should not appear in the target
	// list but is still dispatchable. This is used for routes like bare
	// distro names (e.g. "mariner2") that act as aliases for a default
	// sub-route (e.g. "mariner2/container").
	Hidden bool `json:"hidden,omitempty"`
}

Target wraps bktargets.Target with dalec-specific metadata for richer target list responses.

type TargetList added in v0.21.0

type TargetList struct {
	Targets []Target `json:"targets"`
}

TargetList is the dalec-extended target list response.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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