builder

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

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

func ParseByteSize(s string) (int64, error)

ParseByteSize parses a human-readable byte size string (e.g., "50MB", "100KB").

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
}

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

type CatalogPluginResolver struct {
	Catalog catalog.Catalog
}

CatalogPluginResolver adapts a catalog.Catalog to the bundler.PluginResolver interface.

func (*CatalogPluginResolver) ResolvePlugin

ResolvePlugin resolves a plugin artifact from the catalog by name and kind.

type RegistryFetcherAdapter

type RegistryFetcherAdapter struct {
	Registry *catalog.Registry
}

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 path to the solution file, recorded as an annotation.
	Source string `json:"source,omitempty" yaml:"source,omitempty" doc:"Source file path for annotation"`
}

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"`
}

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.

Jump to

Keyboard shortcuts

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