Skip to content

Commit 24ce254

Browse files
committed
Update activity complete payload input handling
1 parent a6a4f86 commit 24ce254

4 files changed

Lines changed: 13 additions & 17 deletions

File tree

internal/temporalcli/commands.activity.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,7 @@ func (c *TemporalActivityCompleteCommand) run(cctx *CommandContext, args []strin
575575
}
576576
defer cl.Close()
577577

578-
metadata := map[string][][]byte{"encoding": {[]byte("json/plain")}}
579-
resultPayloads, err := CreatePayloads([][]byte{[]byte(c.Result)}, metadata, false)
578+
resultPayloads, err := c.PayloadInputOptions.buildRawInputPayloads()
580579
if err != nil {
581580
return err
582581
}

internal/temporalcli/commands.activity_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func (s *SharedServerSuite) TestActivity_Complete() {
3333
"activity", "complete",
3434
"--activity-id", activityId,
3535
"--workflow-id", wid,
36-
"--result", "\"complete-activity-result\"",
36+
"--input", "\"complete-activity-result\"",
3737
"--identity", identity,
3838
"--address", s.Address(),
3939
)
@@ -88,7 +88,7 @@ func (s *SharedServerSuite) TestActivity_Complete_InvalidResult() {
8888
"activity", "complete",
8989
"--activity-id", activityId,
9090
"--workflow-id", run.GetID(),
91-
"--result", "{not json}",
91+
"--input", "{not json}",
9292
"--address", s.Address(),
9393
)
9494
s.ErrorContains(res.Err, "is not valid JSON")
@@ -1055,7 +1055,7 @@ func (s *SharedServerSuite) TestActivity_Complete_ByRunId() {
10551055
"activity", "complete",
10561056
"--activity-id", "sa-complete-test",
10571057
"--run-id", runID,
1058-
"--result", `"completed-externally"`,
1058+
"--input", `"completed-externally"`,
10591059
"--identity", identity,
10601060
"--address", s.Address(),
10611061
)

internal/temporalcli/commands.gen.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -533,12 +533,12 @@ func NewTemporalActivityCancelCommand(cctx *CommandContext, parent *TemporalActi
533533
}
534534

535535
type TemporalActivityCompleteCommand struct {
536-
Parent *TemporalActivityCommand
537-
Command cobra.Command
536+
Parent *TemporalActivityCommand
537+
Command cobra.Command
538+
PayloadInputOptions
538539
ActivityId string
539540
WorkflowId string
540541
RunId string
541-
Result string
542542
}
543543

544544
func NewTemporalActivityCompleteCommand(cctx *CommandContext, parent *TemporalActivityCommand) *TemporalActivityCompleteCommand {
@@ -548,17 +548,16 @@ func NewTemporalActivityCompleteCommand(cctx *CommandContext, parent *TemporalAc
548548
s.Command.Use = "complete [flags]"
549549
s.Command.Short = "Mark an activity as completed successfully with a result"
550550
if hasHighlighting {
551-
s.Command.Long = "Complete an Activity, marking it as successfully finished. Specify the\nActivity ID and include a JSON result for the returned value:\n\n\x1b[1mtemporal activity complete \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId \\\n --result '{\"YourResultKey\": \"YourResultVal\"}'\x1b[0m"
551+
s.Command.Long = "Complete an Activity, marking it as successfully finished. Specify the\nActivity ID and include a JSON result for the returned value:\n\n\x1b[1mtemporal activity complete \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId \\\n --input '{\"YourResultKey\": \"YourResultVal\"}'\x1b[0m"
552552
} else {
553-
s.Command.Long = "Complete an Activity, marking it as successfully finished. Specify the\nActivity ID and include a JSON result for the returned value:\n\n```\ntemporal activity complete \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId \\\n --result '{\"YourResultKey\": \"YourResultVal\"}'\n```"
553+
s.Command.Long = "Complete an Activity, marking it as successfully finished. Specify the\nActivity ID and include a JSON result for the returned value:\n\n```\ntemporal activity complete \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId \\\n --input '{\"YourResultKey\": \"YourResultVal\"}'\n```"
554554
}
555555
s.Command.Args = cobra.NoArgs
556556
s.Command.Flags().StringVarP(&s.ActivityId, "activity-id", "a", "", "Activity ID. This may be the ID of an Activity invoked by a Workflow, or of a Standalone Activity. Required.")
557557
_ = cobra.MarkFlagRequired(s.Command.Flags(), "activity-id")
558558
s.Command.Flags().StringVarP(&s.WorkflowId, "workflow-id", "w", "", "Workflow ID. Required for workflow Activities. Omit for Standalone Activities.")
559559
s.Command.Flags().StringVarP(&s.RunId, "run-id", "r", "", "Run ID. For workflow Activities (when --workflow-id is provided), this is the Workflow Run ID. For Standalone Activities, this is the Activity Run ID.")
560-
s.Command.Flags().StringVar(&s.Result, "result", "", "Result `JSON` to return. Required.")
561-
_ = cobra.MarkFlagRequired(s.Command.Flags(), "result")
560+
s.PayloadInputOptions.BuildFlags(s.Command.Flags())
562561
s.Command.Run = func(c *cobra.Command, args []string) {
563562
if err := s.run(cctx, args); err != nil {
564563
cctx.Options.Fail(err)

internal/temporalcli/commands.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ commands:
210210
temporal activity complete \
211211
--activity-id YourActivityId \
212212
--workflow-id YourWorkflowId \
213-
--result '{"YourResultKey": "YourResultVal"}'
213+
--input '{"YourResultKey": "YourResultVal"}'
214214
```
215215
options:
216216
- name: activity-id
@@ -233,10 +233,8 @@ commands:
233233
Run ID. For workflow Activities (when --workflow-id is
234234
provided), this is the Workflow Run ID. For Standalone
235235
Activities, this is the Activity Run ID.
236-
- name: result
237-
type: string
238-
description: Result `JSON` to return.
239-
required: true
236+
option-sets:
237+
- payload-input
240238

241239
- name: temporal activity count
242240
summary: Count Standalone Activities matching a query (Experimental)

0 commit comments

Comments
 (0)