common

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LINUX = "linux"
)

Variables

This section is empty.

Functions

func AddImageConfigLabels added in v0.15.0

func AddImageConfigLabels(imageConfig []byte, labels map[string]string) ([]byte, error)

AddImageConfigLabels returns imageConfig with labels merged into its OCI config. The input is left unchanged, and manager-provided values take precedence when a label already exists.

func DisplayProgress

func DisplayProgress(ctx context.Context, eg *errgroup.Group, buildChannel chan *client.SolveStatus, progress progressui.DisplayMode)

DisplayProgress starts a goroutine to display build progress. This encapsulates the common pattern used in both generate and patch commands. Uses progrock-based TUI for improved display when progress mode is auto/tty and TTY is available. Falls back to BuildKit's progressui for explicit modes (plain, quiet, rawjson) or debug mode.

func ExtractOSReleaseFromState added in v0.15.0

func ExtractOSReleaseFromState(ctx context.Context, c gwclient.Client, state *llb.State) ([]byte, error)

ExtractOSReleaseFromState reads /etc/os-release after enforcing the same 1 MiB input limit used by Chisel release inference. The bounded BuildKit helper stats before allocating and uses ranged reads for the file contents.

func ForwardProgressWithPrefix added in v0.13.0

func ForwardProgressWithPrefix(ctx context.Context, src <-chan *client.SolveStatus, dst chan<- *client.SolveStatus, prefix string)

ForwardProgressWithPrefix forwards progress from src to dst, prefixing vertex names with the given prefix. This allows multiplexing multiple build progress streams into a single display.

func GetDefaultLinuxPlatform

func GetDefaultLinuxPlatform() ispec.Platform

GetDefaultLinuxPlatform returns a normalized Linux platform, defaulting to Linux if not already Linux.

func GetRepoNameWithDigest added in v0.12.0

func GetRepoNameWithDigest(patchedImageName, imageDigest string) string

GetRepoNameWithDigest extracts repo name with digest from image name and digest. e.g. "docker.io/library/nginx:1.21.6-patched" -> "nginx@sha256:...".

func MergeImageRuntimeConfig added in v0.15.0

func MergeImageRuntimeConfig(baseConfig, suppliedConfig []byte) ([]byte, error)

MergeImageRuntimeConfig preserves base layer metadata while replacing the runtime config object with the one from the supplied image being repatched.

func ResolvePatchedImageName added in v0.12.0

func ResolvePatchedImageName(imageRef reference.Named, explicitTag, suffix string) (imageName, patchTag string, err error)

ResolvePatchedImageName merges with suffix rules or uses the explicitTag entirely, returning the final patched image name and tag.

func ResolvePatchedTag

func ResolvePatchedTag(imageRef reference.Named, explicitTag, suffix string) (string, error)

ResolvePatchedTag merges explicit tag & suffix rules, returning the final patched tag.

func SetupBuildkitConfigAndManager

func SetupBuildkitConfigAndManager(
	ctx context.Context,
	c gwclient.Client,
	image string,
	platform *ispec.Platform,
	workingFolder string,
	osInfo *OSInfo,
) (*buildkit.Config, pkgmgr.PackageManager, error)

SetupBuildkitConfigAndManager initializes buildkit config and package manager. This combines the common pattern used in both generate and patch commands.

func SetupBuildkitConfigAndManagerWithOptions added in v0.15.0

func SetupBuildkitConfigAndManagerWithOptions(
	ctx context.Context,
	c gwclient.Client,
	image string,
	platform *ispec.Platform,
	workingFolder string,
	osInfo *OSInfo,
	managerOptions pkgmgr.PackageManagerOptions,
) (*buildkit.Config, pkgmgr.PackageManager, error)

SetupBuildkitConfigAndManagerWithOptions initializes BuildKit config and a package manager with optional manager-specific settings.

func StateFileExists added in v0.15.0

func StateFileExists(ctx context.Context, c gwclient.Client, state *llb.State, platform *ispec.Platform, path string) (bool, error)

StateFileExists reports whether path is a regular file in state without reading its contents or executing any binary from the target image. A missing path is not an error; a path with another type is rejected as malformed.

func StatePathExists added in v0.15.0

func StatePathExists(ctx context.Context, c gwclient.Client, state *llb.State, platform *ispec.Platform, path string) (bool, error)

StatePathExists reports whether path exists in state without executing any binary from the target image. A missing path is not an error; solve and stat failures that are not NotFound are returned to the caller.

func TryExtractOSReleaseFromState added in v0.15.0

func TryExtractOSReleaseFromState(ctx context.Context, c gwclient.Client, state *llb.State) ([]byte, bool, error)

TryExtractOSReleaseFromState reads /etc/os-release when present. A genuinely missing file is reported as exists=false; solve, stat, size, and read failures remain errors so callers cannot silently skip OS-dependent safety checks.

Types

type OSInfo

type OSInfo struct {
	Type    string
	Version string
}

OSInfo contains the OS type and version information.

func GetOSInfo

func GetOSInfo(ctx context.Context, osreleaseBytes []byte) (*OSInfo, error)

GetOSInfo extracts OS type and version from os-release data.

Jump to

Keyboard shortcuts

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