( deps commandDeps, use string, short string, execute func(context.Context, DaemonClient, string, TaskExecutionRequest) (TaskExecutionRecord, error), )
| 1296 | } |
| 1297 | |
| 1298 | func newTaskExecutionCommand( |
| 1299 | deps commandDeps, |
| 1300 | use string, |
| 1301 | short string, |
| 1302 | execute func(context.Context, DaemonClient, string, TaskExecutionRequest) (TaskExecutionRecord, error), |
| 1303 | ) *cobra.Command { |
| 1304 | var input taskExecutionInput |
| 1305 | cmd := &cobra.Command{ |
| 1306 | Use: use, |
| 1307 | Short: short, |
| 1308 | Args: exactOneNonBlankArg(), |
| 1309 | RunE: func(cmd *cobra.Command, args []string) error { |
| 1310 | client, err := clientFromDeps(deps) |
| 1311 | if err != nil { |
| 1312 | return err |
| 1313 | } |
| 1314 | request, err := buildTaskExecutionRequest(cmd, input) |
| 1315 | if err != nil { |
| 1316 | return err |
| 1317 | } |
| 1318 | execution, err := execute(cmd.Context(), client, args[0], request) |
| 1319 | if err != nil { |
| 1320 | return err |
| 1321 | } |
| 1322 | return writeCommandOutput(cmd, taskExecutionBundle(&execution)) |
| 1323 | }, |
| 1324 | } |
| 1325 | cmd.Flags().StringVar(&input.IdempotencyKey, "idempotency-key", "", "Optional idempotency key") |
| 1326 | cmd.Flags().StringVar(&input.NetworkRaw, "channel", "", "Optional run channel override") |
| 1327 | cmd.Flags().StringVar(&input.MetadataRaw, "metadata", "", "Optional run metadata JSON") |
| 1328 | return cmd |
| 1329 | } |
| 1330 | |
| 1331 | func buildTaskExecutionRequest( |
| 1332 | cmd *cobra.Command, |
no test coverage detected