Skip to content

Commit

Permalink
chore: validate recipe when saving
Browse files Browse the repository at this point in the history
  • Loading branch information
majori committed Jul 15, 2024
1 parent f29eb68 commit 1670411
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/recipe/saver.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ func ValidatePath(basePath, filePath string) error {

// Save saves recipe to given destination
func (re *Recipe) Save(dest string) error {
if err := re.Validate(); err != nil {
return fmt.Errorf("can not save the recipe since it is not valid: %w", err)
}

err := os.MkdirAll(dest, defaultFileMode)
if err != nil {
return fmt.Errorf("can not create directory %s: %v", dest, err)
Expand Down

0 comments on commit 1670411

Please sign in to comment.