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 ¶
- func NewDefaultGetter(ctx context.Context, noCache bool) get.Interface
- type Option
- func WithAuthRegistry(r *auth.Registry) Option
- func WithClientOptions(opts ...plugin.ClientOption) Option
- func WithDiscoveryMode(mode settings.DiscoveryMode) Option
- func WithGetter(g get.Interface) Option
- func WithLockPlugins(plugins []bundler.LockPlugin) Option
- func WithMetrics(out io.Writer) Option
- func WithNoCache() Option
- func WithPluginConfig(cfg *plugin.ProviderConfig) Option
- func WithPluginFetcher(f *plugin.Fetcher) Option
- func WithRegistry(r *provider.Registry) Option
- func WithStdin(r io.Reader) Option
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDefaultGetter ¶ added in v0.8.0
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
WithRegistry provides a custom provider registry. If not set, builtin.DefaultRegistry is used.
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 ¶
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.