buildkit

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 34 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultAddr = "unix:///run/buildkit/buildkitd.sock"
)

Variables

This section is empty.

Functions

func ArrayFile added in v0.6.0

func ArrayFile(input []string) []byte

func CreateOCILayoutFromResults added in v0.12.0

func CreateOCILayoutFromResults(outputDir string, results []types.PatchResult, platforms []types.PatchPlatform) error

CreateOCILayoutFromResults creates an OCI layout directory from patch results using BuildKit's OCI exporter.

func CreateOCILayoutFromResultsWithOptions added in v0.14.2

func CreateOCILayoutFromResultsWithOptions(outputDir string, results []types.PatchResult, platforms []types.PatchPlatform, exportOpts OCILayoutExportOptions) error

CreateOCILayoutFromResultsWithOptions creates an OCI layout directory from patch results using BuildKit's OCI exporter with the provided export options.

func DiscoverPlatforms added in v0.11.0

func DiscoverPlatforms(manifestRef, reportDir, scanner string) ([]types.PatchPlatform, error)

func DiscoverPlatformsFromReference added in v0.11.0

func DiscoverPlatformsFromReference(manifestRef string) ([]types.PatchPlatform, error)

DiscoverPlatformsFromReference discovers platforms from both local and remote manifests. It first attempts to inspect the manifest locally using Docker API to get raw manifest data and determine if it's multi-platform. If local inspection fails, it falls back to remote registry inspection. This allows Copa to patch multi-platform manifests that exist locally but not in the registry.

func DiscoverPlatformsFromReport added in v0.11.0

func DiscoverPlatformsFromReport(reportDir, scanner string) ([]types.PatchPlatform, error)

func ExtractFileFromState added in v0.6.0

func ExtractFileFromState(ctx context.Context, c gwclient.Client, st *llb.State, path string) ([]byte, error)

Extracts the bytes of the file denoted by `path` from the state `st`.

func GetPlatformImageReference added in v0.12.0

func GetPlatformImageReference(manifestRef string, targetPlatform *specs.Platform) (string, error)

GetPlatformImageReference resolves a platform-specific image reference from a local manifest. For multi-platform images that exist locally but not in the registry, this function extracts the platform-specific digest and constructs a reference that BuildKit can resolve.

func NewClient added in v0.4.0

func NewClient(ctx context.Context, bkOpts Opts) (*client.Client, error)

NewClient returns a new buildkit client with the given addr. If addr is empty it will first try to connect to docker's buildkit instance and then fallback to DefaultAddr.

func PlatformKey added in v0.11.0

func PlatformKey(pl specs.Platform) string

func QemuAvailable added in v0.11.0

func QemuAvailable(p *types.PatchPlatform) bool

func Sh added in v0.7.0

func Sh(cmd string) llb.RunOption

func TryGetManifestFromLocal added in v0.12.0

func TryGetManifestFromLocal(ref name.Reference) (*remote.Descriptor, error)

TryGetManifestFromLocal attempts to get manifest data from the local Docker daemon. It returns a remote.Descriptor if successful, or an error if the manifest cannot be retrieved locally. This is exported to support patching images that exist locally but not in a remote registry.

func ValidateClient added in v0.4.0

func ValidateClient(ctx context.Context, c *client.Client) error

ValidateClient checks to ensure the connected buildkit instance supports the features required by copa.

func WithArrayFile added in v0.6.0

func WithArrayFile(s *llb.State, path string, contents []string) llb.State

func WithFileBytes added in v0.6.0

func WithFileBytes(s *llb.State, path string, contents []byte) llb.State

func WithFileString added in v0.6.0

func WithFileString(s *llb.State, path, contents string) llb.State

Types

type Config

type Config struct {
	ImageName         string
	Client            gwclient.Client
	ConfigData        []byte
	PatchedConfigData []byte
	Platform          *specs.Platform
	ImageState        llb.State
	PatchedImageState llb.State
	// ImageLabels contains OCI labels from the image config (e.g. org.opencontainers.image.*).
	ImageLabels map[string]string
}

func InitializeBuildkitConfig

func InitializeBuildkitConfig(
	ctx context.Context,
	c gwclient.Client,
	userImage string,
	platform *specs.Platform,
) (*Config, error)

type OCILayoutExportOptions added in v0.14.2

type OCILayoutExportOptions struct {
	Compression      string
	ForceCompression bool
}

OCILayoutExportOptions controls BuildKit OCI exporter behavior when writing patched platforms into an OCI image layout. Preserved platforms are copied from the original image as-is to keep their descriptors and layer blobs unchanged.

type Opts added in v0.5.0

type Opts struct {
	Addr       string
	CACertPath string
	CertPath   string
	KeyPath    string
}

type ReadFileErr added in v0.14.0

type ReadFileErr struct {
	// Err is the underlying buildkit error.
	Err error
	// SolveFailed is true when c.Solve(...) itself failed. When true the
	// target file was never actually read, and the failure belongs to the
	// graph that was supposed to produce it. Err may contain shell command
	// text and must not be used for path-based heuristics.
	SolveFailed bool
	// ReadFailed is true when Solve succeeded but ref.ReadFile for the
	// requested path failed. This is the only case where path-based
	// classification (e.g. "missing marker file") is safe.
	ReadFailed bool
}

ReadFileErr distinguishes the cause of a file extraction failure so callers can tell a missing file apart from a solve-time failure of the underlying build graph (which may have included the path in its error text).

func TryExtractFileFromState added in v0.14.0

func TryExtractFileFromState(ctx context.Context, c gwclient.Client, st *llb.State, path string) ([]byte, *ReadFileErr)

TryExtractFileFromState is like ExtractFileFromState but tags the returned error with which phase failed. Prefer this when callers need to treat a missing file differently from a real failure of the build graph.

func (*ReadFileErr) Error added in v0.14.0

func (e *ReadFileErr) Error() string

func (*ReadFileErr) Unwrap added in v0.14.0

func (e *ReadFileErr) Unwrap() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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