| 25 | ) |
| 26 | |
| 27 | func validateJobDefinition(job *Job) error { |
| 28 | if job == nil { |
| 29 | return errors.New("job definition cannot be nil") |
| 30 | } |
| 31 | |
| 32 | if job.Uses != "" && (job.TimeoutMinutes > 0 || job.TimeoutMinutesExpression != "") { |
| 33 | return fmt.Errorf( |
| 34 | "job '%s' uses a reusable workflow and cannot set timeout-minutes; remove timeout-minutes from the caller job or move it into the called workflow", |
| 35 | job.Name, |
| 36 | ) |
| 37 | } |
| 38 | |
| 39 | if job.TimeoutMinutes > 0 && job.TimeoutMinutesExpression != "" { |
| 40 | return fmt.Errorf( |
| 41 | "job '%s' has timeout-minutes set as both integer (%d) and expression (%q); specify only one", |
| 42 | job.Name, |
| 43 | job.TimeoutMinutes, |
| 44 | job.TimeoutMinutesExpression, |
| 45 | ) |
| 46 | } |
| 47 | |
| 48 | return nil |
| 49 | } |
| 50 | |
| 51 | // ValidateDependencies checks that all job dependencies exist and there are no cycles |
| 52 | func (jm *JobManager) ValidateDependencies() error { |