createIssue creates an issue linked to a plan.
(ctx context.Context, project, title, planName, description string)
| 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) { |
| 441 | issue := map[string]any{ |
| 442 | "title": title, |
| 443 | "type": "DATABASE_CHANGE", |
| 444 | "plan": planName, |
| 445 | } |
| 446 | if description != "" { |
| 447 | issue["description"] = description |
| 448 | } |
| 449 | body := map[string]any{ |
| 450 | "parent": project, |
| 451 | "issue": issue, |
| 452 | } |
| 453 | |
| 454 | resp, err := s.apiRequest(ctx, "/bytebase.v1.IssueService/CreateIssue", body) |
| 455 | if err != nil { |
| 456 | return "", "", errors.Wrap(err, "issue creation request failed") |
| 457 | } |
| 458 | if err := checkAPIResponse(resp, "create issues", "bb.issues.create"); err != nil { |
| 459 | return "", "", err |
| 460 | } |
| 461 | |
| 462 | var result struct { |
| 463 | Name string `json:"name"` |
| 464 | ApprovalStatus string `json:"approvalStatus"` |
| 465 | } |
| 466 | if err := json.Unmarshal(resp.Body, &result); err != nil { |
| 467 | return "", "", errors.Wrap(err, "failed to parse CreateIssue response") |
| 468 | } |
| 469 | return result.Name, result.ApprovalStatus, nil |
| 470 | } |
| 471 | |
| 472 | // createRollout creates a rollout for a plan. |
| 473 | func (s *Server) createRollout(ctx context.Context, planName string) (string, error) { |
no test coverage detected