buildkit

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package buildkit provides BuildKit client connectivity for whail.

This subpackage imports moby/buildkit and its transitive dependencies (gRPC, protobuf, containerd, opentelemetry). Consumers who only need whail's label-based Docker wrapper do not pay this cost — only importing this subpackage adds the dependency tree.

Usage:

engine, _ := whail.New(ctx)
engine.BuildKitImageBuilder = buildkit.NewImageBuilder(engine.APIClient)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBuildKitClient

func NewBuildKitClient(ctx context.Context, apiClient DockerDialer) (*bkclient.Client, error)

NewBuildKitClient creates a BuildKit client connected to Docker's embedded buildkitd via the /grpc and /session hijack endpoints. This is the same connection pattern used by docker/buildx internally.

The caller is responsible for calling Close() on the returned client.

func NewImageBuilder

func NewImageBuilder(apiClient DockerDialer) func(context.Context, whail.ImageBuildKitOptions) error

NewImageBuilder returns a closure that builds images using BuildKit's Solve API. The closure is intended to be set on Engine.BuildKitImageBuilder.

If apiClient is nil, the returned closure always returns an error.

Each invocation creates a fresh BuildKit client connection via DialHijack, runs Solve, and closes the connection. Label enforcement is handled by Engine.ImageBuildKit before the closure is called — the closure receives already-merged labels.

Usage:

engine, _ := whail.New(ctx)
engine.BuildKitImageBuilder = buildkit.NewImageBuilder(engine.APIClient)

func VerifyConnection

func VerifyConnection(ctx context.Context, c *bkclient.Client) error

VerifyConnection checks that the BuildKit client can communicate with the daemon and at least one worker is available. This is a spike/diagnostic function — production code should just call Solve and handle errors.

Types

type DockerDialer

type DockerDialer interface {
	DialHijack(ctx context.Context, url, proto string, meta map[string][]string) (net.Conn, error)
}

DockerDialer abstracts the DialHijack capability on the moby client. Engine.APIClient (which embeds *client.Client) satisfies this interface.

Jump to

Keyboard shortcuts

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