LoadFromBytes parses a recipe from YAML bytes.
(data []byte)
| 181 | |
| 182 | // LoadFromBytes parses a recipe from YAML bytes. |
| 183 | func LoadFromBytes(data []byte) (*Recipe, error) { |
| 184 | var recipe Recipe |
| 185 | if err := yaml.Unmarshal(data, &recipe); err != nil { |
| 186 | return nil, fmt.Errorf("parse recipe: %w", err) |
| 187 | } |
| 188 | |
| 189 | if err := recipe.Validate(); err != nil { |
| 190 | return nil, fmt.Errorf("validate recipe: %w", err) |
| 191 | } |
| 192 | |
| 193 | return &recipe, nil |
| 194 | } |
| 195 | |
| 196 | // Validate checks if the recipe is valid. |
| 197 | func (r *Recipe) Validate() error { |