prepare

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 prepare provides a standalone function for loading and preparing a solution for execution. It decouples solution preparation from CLI-specific types, making it reusable by both CLI commands and the MCP server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDefaultGetter added in v0.8.0

func NewDefaultGetter(ctx context.Context, noCache bool) get.Interface

NewDefaultGetter creates a default solution getter with catalog and remote resolution support. When noCache is true, the artifact cache is disabled so the catalog is always queried directly.

Types

type Option

type Option func(*prepareConfig)

Option configures the PrepareSolution function.

func WithAuthRegistry

func WithAuthRegistry(r *auth.Registry) Option

WithAuthRegistry provides an auth handler registry for registering auth handler plugins. If not set, auth handler plugin loading is skipped.

func WithClientOptions added in v0.8.0

func WithClientOptions(opts ...plugin.ClientOption) Option

WithClientOptions provides options for plugin client creation, such as host-side dependencies (secrets, auth) for callback services.

func WithDiscoveryMode added in v0.10.0

func WithDiscoveryMode(mode settings.DiscoveryMode) Option

WithDiscoveryMode sets the discovery mode used when auto-discovering solution files. See settings.DiscoveryMode for available modes.

func WithGetter

func WithGetter(g get.Interface) Option

WithGetter provides a custom solution getter. If not set, one is created from context (with catalog resolution support).

func WithLockPlugins

func WithLockPlugins(plugins []bundler.LockPlugin) Option

WithLockPlugins provides lock file plugin entries for reproducible plugin resolution. When provided, pinned versions and digests are used instead of resolving constraints against catalogs.

func WithMetrics

func WithMetrics(out io.Writer) Option

WithMetrics enables metrics collection and specifies where to write metrics output.

func WithNoCache added in v0.6.0

func WithNoCache() Option

WithNoCache disables artifact caching when loading solutions from the catalog. When set, the catalog is always queried directly, bypassing the filesystem cache.

func WithPluginConfig added in v0.8.0

func WithPluginConfig(cfg *plugin.ProviderConfig) Option

WithPluginConfig provides configuration that is sent to plugin providers after registration via ConfigureProvider. If not set, plugins use defaults.

func WithPluginFetcher

func WithPluginFetcher(f *plugin.Fetcher) Option

WithPluginFetcher provides a plugin fetcher for auto-fetching plugin binaries from catalogs at runtime. If not set, plugin auto-fetching is skipped (plugins must be available via --plugin-dir).

func WithRegistry

func WithRegistry(r *provider.Registry) Option

WithRegistry provides a custom provider registry. If not set, builtin.DefaultRegistry is used.

func WithStdin

func WithStdin(r io.Reader) Option

WithStdin provides a reader for stdin-based solution loading (path == "-").

type Result

type Result struct {
	// Solution is the loaded and prepared solution.
	Solution *solution.Solution `json:"solution" yaml:"solution" doc:"The loaded solution"`
	// Registry is the provider registry with all providers registered,
	// including the solution provider.
	Registry *provider.Registry `json:"-" yaml:"-"`
	// SolutionDir is the directory containing the solution file, resolved to
	// an absolute path. Empty when loaded from stdin or a catalog reference.
	// Callers can use this to set provider.WithSolutionDirectory for relative
	// path resolution during execution.
	SolutionDir string `json:"solutionDir,omitempty" yaml:"solutionDir,omitempty" doc:"Directory containing the solution file"`
	// Cleanup must be deferred by the caller. It handles temp directory
	// removal, working directory restoration, and metrics output.
	Cleanup func() `json:"-" yaml:"-"`
	// DiscoveredFrom holds metadata about how the solution file was discovered.
	// Only populated when auto-discovery is used (path was empty).
	DiscoveredFrom get.DiscoveryResult `json:"-" yaml:"-"`
}

Result holds the output of PrepareSolution.

func Solution

func Solution(ctx context.Context, path string, opts ...Option) (*Result, error)

Solution loads a solution from the given path, extracts any bundle, merges plugin defaults, sets up the provider registry, and registers the solution provider. The returned Result.Cleanup function must be deferred.

This function is the standalone equivalent of the CLI's sharedResolverOptions.prepareSolutionForExecution method, decoupled from CLI-specific types so it can be used by the MCP server and other callers.

Jump to

Keyboard shortcuts

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