(blueprint *models.Blueprint, syncPolicy *models.SyncPolicy)
| 310 | } |
| 311 | |
| 312 | func createPipelineByBlueprint(blueprint *models.Blueprint, syncPolicy *models.SyncPolicy) (*models.Pipeline, errors.Error) { |
| 313 | var plan models.PipelinePlan |
| 314 | var err errors.Error |
| 315 | if blueprint.Mode == models.BLUEPRINT_MODE_NORMAL { |
| 316 | plan, err = MakePlanForBlueprint(blueprint, syncPolicy) |
| 317 | if err != nil { |
| 318 | blueprintLog.Error(err, fmt.Sprintf("failed to MakePlanForBlueprint on blueprint:[%d][%s]", blueprint.ID, blueprint.Name)) |
| 319 | return nil, err |
| 320 | } |
| 321 | } else { |
| 322 | plan = blueprint.Plan |
| 323 | } |
| 324 | |
| 325 | newPipeline := models.NewPipeline{} |
| 326 | newPipeline.Plan = plan |
| 327 | newPipeline.Name = blueprint.Name |
| 328 | newPipeline.BlueprintId = blueprint.ID |
| 329 | newPipeline.Labels = blueprint.Labels |
| 330 | newPipeline.Priority = blueprint.Priority |
| 331 | newPipeline.SyncPolicy = blueprint.SyncPolicy |
| 332 | |
| 333 | // if the plan is empty, we should not create the pipeline |
| 334 | // var shouldCreatePipeline bool |
| 335 | // for _, stage := range plan { |
| 336 | // for _, task := range stage { |
| 337 | // switch task.Plugin { |
| 338 | // case "org", "refdiff", "dora": |
| 339 | // default: |
| 340 | // if !plan.IsEmpty() { |
| 341 | // shouldCreatePipeline = true |
| 342 | // } |
| 343 | // } |
| 344 | // } |
| 345 | // } |
| 346 | // if !shouldCreatePipeline { |
| 347 | // return nil, ErrEmptyPlan |
| 348 | // } |
| 349 | pipeline, err := CreatePipeline(&newPipeline, false) |
| 350 | // Return all created tasks to the User |
| 351 | if err != nil { |
| 352 | blueprintLog.Error(err, fmt.Sprintf("%s on blueprint:[%d][%s]", failToCreateCronJob, blueprint.ID, blueprint.Name)) |
| 353 | return nil, errors.Convert(err) |
| 354 | } |
| 355 | return pipeline, nil |
| 356 | } |
| 357 | |
| 358 | // MakePlanForBlueprint generates pipeline plan by version |
| 359 | func MakePlanForBlueprint(blueprint *models.Blueprint, syncPolicy *models.SyncPolicy) (models.PipelinePlan, errors.Error) { |
no test coverage detected