deferredUpdateIssueOptions resolves the user-supplied --type / --parent / --blocked-by / --blocking flags into the IDs that DeferredUpdateIssue expects.
(client *api.Client, baseRepo ghrepo.Interface, issue *api.Issue, opts *CreateOptions)
| 501 | // --blocked-by / --blocking flags into the IDs that DeferredUpdateIssue |
| 502 | // expects. |
| 503 | func deferredUpdateIssueOptions(client *api.Client, baseRepo ghrepo.Interface, issue *api.Issue, opts *CreateOptions) (api.DeferredUpdateIssueOptions, error) { |
| 504 | updateOpts := api.DeferredUpdateIssueOptions{ |
| 505 | IssueID: issue.ID, |
| 506 | Hostname: baseRepo.RepoHost(), |
| 507 | } |
| 508 | |
| 509 | if opts.IssueType != "" { |
| 510 | typeID := opts.issueTypeID |
| 511 | if typeID == "" { |
| 512 | var err error |
| 513 | typeID, err = issueShared.ResolveIssueTypeName(client, baseRepo, opts.IssueType) |
| 514 | if err != nil { |
| 515 | return api.DeferredUpdateIssueOptions{}, err |
| 516 | } |
| 517 | } |
| 518 | updateOpts.IssueTypeID = typeID |
| 519 | } |
| 520 | |
| 521 | if opts.Parent != "" { |
| 522 | parentID, err := issueShared.ResolveIssueRef(client, baseRepo, opts.Parent) |
| 523 | if err != nil { |
| 524 | return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --parent reference %q: %w", opts.Parent, err) |
| 525 | } |
| 526 | updateOpts.ParentID = parentID |
| 527 | } |
| 528 | |
| 529 | for _, ref := range opts.BlockedBy { |
| 530 | id, err := issueShared.ResolveIssueRef(client, baseRepo, ref) |
| 531 | if err != nil { |
| 532 | return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --blocked-by reference %q: %w", ref, err) |
| 533 | } |
| 534 | updateOpts.AddBlockedByIDs = append(updateOpts.AddBlockedByIDs, id) |
| 535 | } |
| 536 | |
| 537 | for _, ref := range opts.Blocking { |
| 538 | id, err := issueShared.ResolveIssueRef(client, baseRepo, ref) |
| 539 | if err != nil { |
| 540 | return api.DeferredUpdateIssueOptions{}, fmt.Errorf("resolving --blocking reference %q: %w", ref, err) |
| 541 | } |
| 542 | updateOpts.AddBlockingIDs = append(updateOpts.AddBlockingIDs, id) |
| 543 | } |
| 544 | |
| 545 | return updateOpts, nil |
| 546 | } |