Documentation
¶
Overview ¶
Package builder provides the build pipeline for composing, discovering, vendoring, and bundling solution artifacts. This is the shared domain layer used by CLI, MCP, and future API consumers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseByteSize ¶
ParseByteSize parses a human-readable byte size string (e.g., "50MB", "100KB").
func WriteBuildCacheEntry ¶ added in v0.35.0
func WriteBuildCacheEntry(ctx context.Context, result *StoreResult) bool
WriteBuildCacheEntry writes the build-cache entry for a stored artifact. It is separated from StoreSolutionArtifact so callers can defer the cache write until after post-store verification passes (see StoreOptions.DeferBuildCache): a build-cache entry must only exist for artifacts that verified successfully, otherwise a rerun would hit the cache and exit 0 without re-verifying a broken artifact. It returns true when an entry was written.
Types ¶
type BuildBundleOptions ¶
type BuildBundleOptions struct {
// BundleMaxSize is the maximum total size for bundled files (e.g., "50MB").
BundleMaxSize string `json:"bundleMaxSize,omitempty" yaml:"bundleMaxSize,omitempty" doc:"Maximum total size for bundled files"`
// NoVendor skips catalog dependency vendoring.
NoVendor bool `json:"noVendor,omitempty" yaml:"noVendor,omitempty" doc:"Skip catalog dependency vendoring"`
// NoCache skips the build cache and forces a full rebuild.
NoCache bool `json:"noCache,omitempty" yaml:"noCache,omitempty" doc:"Skip build cache and force a full rebuild"`
// DryRun previews what would be bundled without writing anything.
DryRun bool `json:"dryRun,omitempty" yaml:"dryRun,omitempty" doc:"Show what would be bundled without storing"`
// Dedupe enables content-addressable deduplication.
Dedupe bool `json:"dedupe,omitempty" yaml:"dedupe,omitempty" doc:"Enable content-addressable deduplication"`
// DedupeThreshold is the minimum file size for individual layer extraction.
DedupeThreshold string `json:"dedupeThreshold,omitempty" yaml:"dedupeThreshold,omitempty" doc:"Minimum file size for individual layer extraction"`
// Logger is used for structured logging during the build.
Logger logr.Logger
// OfficialProviders is the official provider registry for auto-injecting
// missing providers into bundle.plugins at build time. When nil, no
// auto-injection occurs.
OfficialProviders *official.Registry
// Strict disables auto-injection of official providers. When true,
// missing official providers produce a build error.
Strict bool
}
BuildBundleOptions holds configuration for the build bundle pipeline.
type BuildResult ¶
type BuildResult struct {
// TarData is the traditional single tar archive (v1).
TarData []byte
// Dedup is the content-addressable dedup result (v2).
Dedup *bundler.DedupeResult
// CacheHit indicates the build was served from the build cache.
// When true, the artifact already exists in the catalog and no store is needed.
CacheHit bool
// CacheEntry contains the cache metadata when CacheHit is true.
CacheEntry *bundler.BuildCacheEntry
// BuildFingerprint is the computed fingerprint for cache write after a successful build.
BuildFingerprint string
// BuildCacheDir is the directory where build cache entries are stored.
BuildCacheDir string
// InputFileCount is the number of input files that contributed to the fingerprint.
InputFileCount int
// ResolvedPlugins holds plugin lock entries from VendorPlugins,
// to be merged into the lock file during the store step.
ResolvedPlugins []bundler.LockPlugin
// Discovery holds the file discovery results (always populated).
Discovery *bundler.DiscoveryResult
// Messages collects human-readable progress messages generated during
// the pipeline. CLI consumers should display these to the user.
Messages []string
}
BuildResult holds the output of the build bundle pipeline.
func BuildBundle ¶
func BuildBundle(ctx context.Context, sol *solution.Solution, solutionContent []byte, bundleRoot string, opts BuildBundleOptions) (*BuildResult, error)
BuildBundle runs the compose → discover → vendor → tar/dedup pipeline.
The solution (sol) may be mutated by the compose step. solutionContent is the raw YAML bytes of the original solution file. bundleRoot is the directory containing the solution file.
type CatalogPluginResolver ¶
CatalogPluginResolver adapts a catalog.Catalog to the bundler.PluginResolver interface.
func (*CatalogPluginResolver) ResolvePlugin ¶
func (r *CatalogPluginResolver) ResolvePlugin(ctx context.Context, name string, kind catalog.ArtifactKind, _ string) (catalog.ArtifactInfo, error)
ResolvePlugin resolves a plugin artifact from the catalog by name and kind.
type PreflightOptions ¶ added in v0.8.0
type PreflightOptions struct {
// SkipLint skips the lint pre-flight check entirely.
SkipLint bool `json:"skipLint,omitempty" yaml:"skipLint,omitempty" doc:"Skip lint pre-flight check"`
// SkipTests skips the functional test pre-flight check entirely.
SkipTests bool `json:"skipTests,omitempty" yaml:"skipTests,omitempty" doc:"Skip functional test pre-flight check"`
// IgnorePreflight runs checks but treats errors as warnings instead of blocking.
IgnorePreflight bool `json:"ignorePreflight,omitempty" yaml:"ignorePreflight,omitempty" doc:"Run checks but treat errors as warnings"`
// BinaryPath is the CLI executable path used for test execution.
// When empty, functional test pre-flight checks are skipped.
BinaryPath string `json:"binaryPath,omitempty" yaml:"binaryPath,omitempty" doc:"Binary path for test execution"`
// Registry is the provider registry for lint to validate against.
// When nil, lint skips provider-specific checks.
Registry *provider.Registry `json:"-" yaml:"-"`
// Logger is used for structured logging.
Logger logr.Logger
}
PreflightOptions controls which pre-flight checks run before a build.
type PreflightResult ¶ added in v0.8.0
type PreflightResult struct {
// LintResult contains lint findings. Nil if lint was skipped.
LintResult *lint.Result `json:"lintResult,omitempty" yaml:"lintResult,omitempty" doc:"Lint findings"`
// TestsPassed is true if tests passed or were skipped.
TestsPassed bool `json:"testsPassed" yaml:"testsPassed" doc:"Whether tests passed or were skipped"`
// Blocked is true if the build should be aborted.
Blocked bool `json:"blocked" yaml:"blocked" doc:"Whether the build should be aborted"`
// Messages collects human-readable status lines for display.
Messages []string `json:"messages,omitempty" yaml:"messages,omitempty" doc:"Human-readable status lines"`
}
PreflightResult holds the outcome of pre-flight validation.
func RunPreflight ¶ added in v0.8.0
func RunPreflight(ctx context.Context, sol *solution.Solution, filePath string, opts PreflightOptions) (*PreflightResult, error)
RunPreflight executes lint and (optionally) functional tests against the parsed solution. Returns a result indicating whether the build should proceed.
type RegistryFetcherAdapter ¶
RegistryFetcherAdapter adapts a catalog.Registry to the bundler.CatalogFetcher interface. It supports both exact version fetches and listing all versions for constraint resolution.
func (*RegistryFetcherAdapter) FetchSolution ¶
func (a *RegistryFetcherAdapter) FetchSolution(ctx context.Context, nameWithVersion string) ([]byte, catalog.ArtifactInfo, error)
FetchSolution retrieves a solution by name[@version] from the registry.
func (*RegistryFetcherAdapter) ListSolutions ¶
func (a *RegistryFetcherAdapter) ListSolutions(ctx context.Context, name string) ([]catalog.ArtifactInfo, error)
ListSolutions returns all available versions of a named solution artifact.
type StoreOptions ¶ added in v0.6.0
type StoreOptions struct {
// Force overwrites an existing version in the catalog.
Force bool `json:"force,omitempty" yaml:"force,omitempty" doc:"Overwrite existing version"`
// Source is the origin of the solution (repository URL or file path), stored as org.opencontainers.image.source.
Source string `json:"source,omitempty" yaml:"source,omitempty" doc:"Source repository URL or file path"`
// DisplayName is the human-readable name, stored as an OCI annotation.
DisplayName string `json:"displayName,omitempty" yaml:"displayName,omitempty" doc:"Human-readable display name"`
// Description is the solution description, stored as an OCI annotation.
Description string `json:"description,omitempty" yaml:"description,omitempty" doc:"Solution description"`
// Category classifies the solution, stored as an OCI annotation.
Category string `json:"category,omitempty" yaml:"category,omitempty" doc:"Solution category"`
// Tags are searchable keywords, stored as a comma-separated OCI annotation.
Tags []string `json:"tags,omitempty" yaml:"tags,omitempty" doc:"Searchable tags"`
// Annotations is a free-form map merged into OCI annotations.
// Engine-set annotations take precedence over user-supplied ones.
Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty" doc:"User-supplied annotations"`
// ArtifactCacheDir is the path to the artifact cache directory.
// When non-empty, the corresponding artifact cache entry is invalidated
// after a successful store to prevent stale reads on subsequent runs.
ArtifactCacheDir string `json:"-" yaml:"-" doc:"Artifact cache directory path"`
// ArtifactCacheTTL is the TTL for the artifact cache.
// Required when ArtifactCacheDir is set.
ArtifactCacheTTL time.Duration `json:"-" yaml:"-" doc:"Artifact cache TTL"`
// DeferBuildCache, when true, skips writing the build-cache entry during the
// store. The caller is expected to call WriteBuildCacheEntry only after any
// post-store verification passes, so a failed verification does not leave a
// build-cache entry that would let a rerun hit a cached broken artifact and
// exit 0 without re-verifying.
DeferBuildCache bool `json:"-" yaml:"-" doc:"Skip writing the build cache entry during store"`
}
StoreOptions configures how a solution artifact is stored.
type StoreResult ¶ added in v0.6.0
type StoreResult struct {
// Info is the catalog artifact info returned after storing.
Info catalog.ArtifactInfo `json:"info" yaml:"info" doc:"Artifact info from the catalog"`
// CacheWritten indicates whether a build cache entry was written.
CacheWritten bool `json:"cacheWritten,omitempty" yaml:"cacheWritten,omitempty" doc:"Whether the build cache entry was written"`
// contains filtered or unexported fields
}
StoreResult holds the outcome of a store operation.
func StoreSolutionArtifact ¶ added in v0.6.0
func StoreSolutionArtifact(ctx context.Context, localCatalog *catalog.LocalCatalog, name string, version *semver.Version, content []byte, br *BuildResult, opts StoreOptions) (*StoreResult, error)
StoreSolutionArtifact stores a built solution artifact in the local catalog, choosing between dedup (v2) and traditional (v1) storage based on the build result. It also writes a build cache entry when applicable.