builder

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: Apache-2.0 Imports: 22 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 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

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

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

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

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