Skip to content

presets

import "github.com/alehatsman/mooncake/internal/presets"

Package presets provides preset loading and expansion functionality.

Index

func ExpandPreset

func ExpandPreset(invocation *config.PresetInvocation) ([]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 LoadPreset

func LoadPreset(name string) (*config.PresetDefinition, error)

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 PresetSearchPaths

func PresetSearchPaths() []string

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)

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.

Generated by gomarkdoc