courgette/internal/commands/validate.go

28 lines
496 B
Go
Raw Normal View History

package commands
import (
"errors"
"log"
workflow "runner/internal/workflow"
)
func ValidateWorkflow(configuration Configuration, workflowPath string) error {
workflow, err := workflow.FromYamlFile(workflowPath)
if err != nil {
log.Fatalf("%#v", err)
}
validationErrors := workflow.Validate()
if len(validationErrors) > 0 {
for _, err := range validationErrors {
log.Printf("Validation error:: %#v", err)
}
return errors.New("Jobs encountered errors.")
}
return nil
}