MCPcopy Create free account
hub / github.com/astercloud/aster / LoadFromBytes

Function LoadFromBytes

pkg/recipe/recipe.go:183–194  ·  view source on GitHub ↗

LoadFromBytes parses a recipe from YAML bytes.

(data []byte)

Source from the content-addressed store, hash-verified

181
182// LoadFromBytes parses a recipe from YAML bytes.
183func 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.
197func (r *Recipe) Validate() error {

Callers 3

TestLoadFromBytesFunction · 0.85
TestToYAMLFunction · 0.85
LoadFromFileFunction · 0.85

Calls 1

ValidateMethod · 0.95

Tested by 2

TestLoadFromBytesFunction · 0.68
TestToYAMLFunction · 0.68