frontend

package
v0.10.4 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: MIT Imports: 31 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 added in v0.3.0

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 tarrget platform and executing the build with the platform args substituted in the spec. This also deals with the docker-style multi-platform output.

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 GetBuildArg

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

func GetTargetKey added in v0.3.0

func GetTargetKey(client BuildOpstGetter) string

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

func LoadSpec added in v0.3.0

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

func MaybeSign added in v0.7.0

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

func RunTests

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

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

func SourceOptFromClient

func SourceOptFromClient(ctx context.Context, c gwclient.Client) (dalec.SourceOpts, error)

func SupportsDiffMerge

func SupportsDiffMerge(client gwclient.Client) bool

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

func Warn added in v0.7.0

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

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

func WithBuiltinHandler added in v0.3.0

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 WithTargetForwardingHandler added in v0.3.0

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

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

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

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

func (*BuildMux) Handle added in v0.3.0

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

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

type BuildOpstGetter interface {
	BuildOpts() gwclient.BuildOpts
}

type CurrentFrontend added in v0.3.0

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 PlatformBuildFunc added in v0.3.0

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