Documentation
¶
Index ¶
- Constants
- func ArrayFile(input []string) []byte
- func CreateOCILayoutFromResults(outputDir string, results []types.PatchResult, platforms []types.PatchPlatform) error
- func CreateOCILayoutFromResultsWithOptions(outputDir string, results []types.PatchResult, platforms []types.PatchPlatform, ...) error
- func DiscoverPlatforms(manifestRef, reportDir, scanner string) ([]types.PatchPlatform, error)
- func DiscoverPlatformsFromReference(manifestRef string) ([]types.PatchPlatform, error)
- func DiscoverPlatformsFromReport(reportDir, scanner string) ([]types.PatchPlatform, error)
- func ExtractFileFromState(ctx context.Context, c gwclient.Client, st *llb.State, path string) ([]byte, error)
- func GetPlatformImageReference(manifestRef string, targetPlatform *specs.Platform) (string, error)
- func NewClient(ctx context.Context, bkOpts Opts) (*client.Client, error)
- func PlatformKey(pl specs.Platform) string
- func QemuAvailable(p *types.PatchPlatform) bool
- func Sh(cmd string) llb.RunOption
- func TryGetManifestFromLocal(ref name.Reference) (*remote.Descriptor, error)
- func ValidateClient(ctx context.Context, c *client.Client) error
- func WithArrayFile(s *llb.State, path string, contents []string) llb.State
- func WithFileBytes(s *llb.State, path string, contents []byte) llb.State
- func WithFileString(s *llb.State, path, contents string) llb.State
- type Config
- type OCILayoutExportOptions
- type Opts
- type ReadFileErr
Constants ¶
const (
DefaultAddr = "unix:///run/buildkit/buildkitd.sock"
)
Variables ¶
This section is empty.
Functions ¶
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
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
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 QemuAvailable ¶ added in v0.11.0
func QemuAvailable(p *types.PatchPlatform) bool
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
ValidateClient checks to ensure the connected buildkit instance supports the features required by copa.
func WithArrayFile ¶ added in v0.6.0
func WithFileBytes ¶ added in v0.6.0
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
}
type OCILayoutExportOptions ¶ added in v0.14.2
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 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