buildPlanCheckInfo converts a completed plan check run into PlanCheckInfo.
(run planCheckRunResponse)
| 413 | |
| 414 | // buildPlanCheckInfo converts a completed plan check run into PlanCheckInfo. |
| 415 | func buildPlanCheckInfo(run planCheckRunResponse) *PlanCheckInfo { |
| 416 | info := &PlanCheckInfo{ |
| 417 | Status: planCheckDone, |
| 418 | Summary: &PlanCheckSummary{}, |
| 419 | } |
| 420 | for _, r := range run.Results { |
| 421 | msg := r.Title |
| 422 | if msg == "" { |
| 423 | msg = r.Content |
| 424 | } |
| 425 | switch r.Status { |
| 426 | case "ERROR": |
| 427 | info.Summary.Error++ |
| 428 | info.Results = append(info.Results, PlanCheckResult{Type: "ERROR", Message: msg}) |
| 429 | case "WARNING": |
| 430 | info.Summary.Warning++ |
| 431 | info.Results = append(info.Results, PlanCheckResult{Type: "WARNING", Message: msg}) |
| 432 | default: |
| 433 | // SUCCESS and other statuses are not included in the output. |
| 434 | } |
| 435 | } |
| 436 | return info |
| 437 | } |
| 438 | |
| 439 | // createIssue creates an issue linked to a plan. |
| 440 | func (s *Server) createIssue(ctx context.Context, project, title, planName, description string) (string, string, error) { |