(deps commandDeps)
| 982 | } |
| 983 | |
| 984 | func newTaskReviewRequestCommand(deps commandDeps) *cobra.Command { |
| 985 | var ( |
| 986 | reasonRaw string |
| 987 | policyRaw string |
| 988 | round int |
| 989 | attempt int |
| 990 | parentID string |
| 991 | asAgent bool |
| 992 | ) |
| 993 | cmd := &cobra.Command{ |
| 994 | Use: "request <run-id>", |
| 995 | Short: "Request review for a task run", |
| 996 | Args: exactOneNonBlankArg(), |
| 997 | RunE: func(cmd *cobra.Command, args []string) error { |
| 998 | client, err := clientFromDeps(deps) |
| 999 | if err != nil { |
| 1000 | return err |
| 1001 | } |
| 1002 | request, err := buildTaskRunReviewRequest( |
| 1003 | args[0], |
| 1004 | reasonRaw, |
| 1005 | policyRaw, |
| 1006 | round, |
| 1007 | attempt, |
| 1008 | parentID, |
| 1009 | ) |
| 1010 | if err != nil { |
| 1011 | return err |
| 1012 | } |
| 1013 | var review TaskRunReviewRequestRecord |
| 1014 | if asAgent { |
| 1015 | credentials, identityErr := requireAgentCommandIdentity( |
| 1016 | cmd.Context(), |
| 1017 | deps, |
| 1018 | client, |
| 1019 | agentActionCLI("task.review.request"), |
| 1020 | ) |
| 1021 | if identityErr != nil { |
| 1022 | return identityErr |
| 1023 | } |
| 1024 | review, err = client.RequestTaskRunReviewAsAgent( |
| 1025 | cmd.Context(), |
| 1026 | args[0], |
| 1027 | request, |
| 1028 | credentials, |
| 1029 | ) |
| 1030 | } else { |
| 1031 | review, err = client.RequestTaskRunReview(cmd.Context(), args[0], request) |
| 1032 | } |
| 1033 | if err != nil { |
| 1034 | return err |
| 1035 | } |
| 1036 | return writeCommandOutput(cmd, taskRunReviewRequestBundle(&review)) |
| 1037 | }, |
| 1038 | } |
| 1039 | cmd.Flags().StringVar(&reasonRaw, "reason", "", "Reason for requesting review") |
| 1040 | cmd.Flags(). |
| 1041 | StringVar(&policyRaw, "policy", "", "Review policy: always, on_success, or on_failure") |
no test coverage detected