func setStages(pipe *models.Pipeline, ctx *Context, stages []string) bool { if len(stages) == 0 { return false } if err := pipe.SetStages(stages...); err != nil { if models.IsErrStageNotExist(err) { ctx.Handle(422, err) } else { ctx.Handle(500, "Fail to add stages to pipeline: '%s': %v", pipe.UUID, err) } return true } return false }
func setPrerequisites(pipe *models.Pipeline, ctx *Context, requires []string) bool { if len(requires) == 0 { return false } if err := pipe.SetPrerequisites(requires...); err != nil { if models.IsErrPipelineNotExist(err) || models.IsErrCircularDependencies(err) { ctx.Handle(422, err) } else { ctx.Handle(500, "Fail to add prerequisites to pipeline '%s': %v", pipe.UUID, err) } return true } return false }