presets¶
Package presets provides preset loading and expansion functionality.
Index¶
- Variables
- func ExpandPreset(name string, props map[string]interface{}) ([]config.Step, map[string]interface{}, string, error)
- func ExpandPresetFromPath(name string, props map[string]interface{}, absPath string) ([]config.Step, map[string]interface{}, string, error)
- func LoadPreset(name string) (*config.PresetDefinition, error)
- func LoadPresetFromPath(path string) (*config.PresetDefinition, error)
- func ValidateParameters(definition *config.PresetDefinition, userParams map[string]interface{}) (map[string]interface{}, error)
- type PresetInfo
- func DiscoverAllPresets() ([]PresetInfo, error)
Variables¶
PresetSearchPaths returns the ordered list of directories to search for presets. Priority order (highest to lowest): 1. ./presets/ (playbook directory) 2. \~/.mooncake/presets/ (user presets) 3. /usr/local/share/mooncake/presets/ (local installation) 4. /usr/share/mooncake/presets/ (system installation)
Implemented as a package-level variable so tests can stub discovery to a hermetic path set. Production code calls it as a function; callers don't need to know it's a variable.
func ExpandPreset¶
func ExpandPreset(name string, props map[string]interface{}) ([]config.Step, map[string]interface{}, string, error)
ExpandPreset expands a preset invocation into its constituent steps. It loads the preset definition, validates parameters, and returns the expanded steps with the 'parameters' namespace injected into the execution context, along with the preset's base directory for relative path resolution.
func ExpandPresetFromPath¶
func ExpandPresetFromPath(name string, props map[string]interface{}, absPath string) ([]config.Step, map[string]interface{}, string, error)
ExpandPresetFromPath is the spec-67 entry point for `use: ./foo.yml` style invocations. The caller has already resolved the path to an absolute location; this function loads the definition, validates props, and returns the expanded steps along with the namespace and base directory.
func LoadPreset¶
LoadPreset loads a preset definition by name. It searches for presets in two formats: 1. Flat: \<name>.yml (e.g., presets/ollama.yml) 2. Directory: \<name>/preset.yml (e.g., presets/ollama/preset.yml) Directory structure takes precedence if both exist. Returns the loaded PresetDefinition or an error if not found or invalid.
func LoadPresetFromPath¶
LoadPresetFromPath loads a component/preset definition from an explicit filesystem path. Used by spec-67 local-component (`use: ./foo.yml`) and remote-module dispatch, where the loader has already resolved the file without going through search paths.
If the file omits `name:`, the filename stem is used so downstream code that expects a non-empty Name still works.
func ValidateParameters¶
func ValidateParameters(definition *config.PresetDefinition, userParams map[string]interface{}) (map[string]interface{}, error)
ValidateParameters validates user-provided parameters against preset parameter definitions. It checks required parameters, validates types, checks enum constraints, and applies defaults. Returns a validated parameter map ready for use in template expansion.
type PresetInfo¶
PresetInfo contains summary information about a discovered preset.
type PresetInfo struct {
Name string
Description string
Version string
Path string
Source string // "local", "user", "system"
}
func DiscoverAllPresets¶
DiscoverAllPresets finds all available presets in the search paths. Returns a sorted list of PresetInfo structs.
Generated by gomarkdoc