Skip to content

Commit c67392f

Browse files
[CAP-7984] rename taskIdentifier to taskSlug and regenerate types (#333)
GitOrigin-RevId: 803eb91f2a2f5a365c0eb5f1788d4cc7e43949f9
1 parent ae6d3fb commit c67392f

13 files changed

Lines changed: 70 additions & 81 deletions

File tree

cmd/runlist.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ func NewRunListCmd(deps flows.WorkflowDeps) *cobra.Command {
2121
A task run represents a single execution of a task with specific input parameters.
2222
This command shows the history of all runs for a given task.
2323
24-
You can specify the task by:
25-
• Task ID (e.g., tsk-1234)
26-
• Workflow slug and task name (e.g., my-workflow/my-task)
24+
You can specify the task by its workflow slug and task name (e.g., my-workflow/my-task)
2725
2826
In interactive mode, you will be prompted to select a task if not provided.
2927

cmd/task.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,11 @@ var taskCmd = &cobra.Command{
2323

2424
func NewTaskStartCmd(deps flows.WorkflowDeps) *cobra.Command {
2525
cmd := &cobra.Command{
26-
Use: "start [taskID] --input=<json>",
26+
Use: "start [task-slug] --input=<json>",
2727
Short: "Start a task run with the provided input",
2828
Long: `Start a task with the provided input.
2929
30-
You can specify the task by:
31-
• Task ID (e.g., tsk-1234)
32-
• Workflow slug and task name (e.g., my-workflow/my-task)
30+
You can specify the task by its workflow slug and task name (e.g., my-workflow/my-task)
3331
3432
Input Format:
3533
The input should be a JSON array where each element is an argument to the task.
@@ -73,15 +71,15 @@ Examples:
7371
return fmt.Errorf("failed to parse input: %w", err)
7472
}
7573

76-
if input.TaskID != "" && cmd.Flags().Changed("input") {
74+
if input.TaskSlug != "" && cmd.Flags().Changed("input") {
7775
command.DefaultFormatNonInteractive(cmd)
7876
}
7977

8078
if nonInteractive, err := command.NonInteractive(cmd, func() (*workflows.TaskRun, error) {
8179
taskLoader := deps.WorkflowLoader()
8280
return taskLoader.CreateTaskRun(cmd.Context(), input)
8381
}, func(j *workflows.TaskRun) string {
84-
return text.FormatStringF("Created task run %s for %s", j.Id, input.TaskID)
82+
return text.FormatStringF("Created task run %s for %s", j.Id, input.TaskSlug)
8583
}); err != nil {
8684
return err
8785
} else if nonInteractive {

pkg/client/client_gen.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/client/types_gen.go

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/client/workflows/workflows_gen.go

Lines changed: 7 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/tasks/repo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ type Repo struct {
1616
client *client.ClientWithResponses
1717
}
1818

19-
func (r *Repo) RunTask(ctx context.Context, taskID string, input *workflows.TaskData) (*workflows.TaskRun, error) {
19+
func (r *Repo) RunTask(ctx context.Context, taskSlug string, input *workflows.TaskData) (*workflows.TaskRun, error) {
2020
resp, err := r.client.CreateTaskWithResponse(ctx, client.CreateTaskJSONRequestBody{
21-
Task: taskID,
21+
Task: taskSlug,
2222
Input: *input,
2323
})
2424

pkg/tui/flows/workflow.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ func NewWorkflow(deps WorkflowDeps, logsFlow *LogFlow, local bool) *Workflow {
4343
}
4444

4545
func (f *Workflow) TaskRunFlow(ctx context.Context, input *workflowviews.TaskRunInput) tea.Cmd {
46-
if input.TaskID == "" {
46+
if input.TaskSlug == "" {
4747
return f.unspecifiedTask(ctx, func(t *workflows.Task) tea.Cmd {
48-
input.TaskID = t.Id
48+
input.TaskSlug = t.Id
4949
return f.taskRun(ctx, input)
5050
})
5151
}
@@ -66,9 +66,9 @@ func (f *Workflow) TaskListFlow(ctx context.Context, input *workflowviews.TaskLi
6666
}
6767

6868
func (f *Workflow) RunListFlow(ctx context.Context, input *workflowviews.TaskRunListInput) tea.Cmd {
69-
if input.TaskID == "" {
69+
if input.TaskSlug == "" {
7070
return f.unspecifiedTask(ctx, func(t *workflows.Task) tea.Cmd {
71-
input.TaskID = t.Id
71+
input.TaskSlug = t.Id
7272
return f.runList(ctx, input, func(tr *workflows.TaskRun) tea.Cmd {
7373
return f.runListPalette(ctx, tr)
7474
})
@@ -292,14 +292,14 @@ func (f *Workflow) taskListPalette(ctx context.Context, t *workflows.Task) tea.C
292292
Name: "runs",
293293
Description: "View all runs for this task",
294294
Action: func(ctx context.Context, args []string) tea.Cmd {
295-
return f.RunListFlow(ctx, &workflowviews.TaskRunListInput{TaskID: t.Id})
295+
return f.RunListFlow(ctx, &workflowviews.TaskRunListInput{TaskSlug: t.Id})
296296
},
297297
},
298298
{
299299
Name: "run",
300300
Description: "Start a new task run with inputs",
301301
Action: func(ctx context.Context, args []string) tea.Cmd {
302-
return f.TaskRunFlow(ctx, &workflowviews.TaskRunInput{TaskID: t.Id})
302+
return f.TaskRunFlow(ctx, &workflowviews.TaskRunInput{TaskSlug: t.Id})
303303
},
304304
},
305305
}),
@@ -369,7 +369,7 @@ func (f *Workflow) runDetails(ctx context.Context, input *workflowviews.TaskRunD
369369
func (f *Workflow) RunDetailsFlow(ctx context.Context, input *workflowviews.TaskRunDetailsInput) tea.Cmd {
370370
if input.TaskRunID == "" {
371371
return f.unspecifiedTask(ctx, func(t *workflows.Task) tea.Cmd {
372-
return f.runList(ctx, &workflowviews.TaskRunListInput{TaskID: t.Id}, func(tr *workflows.TaskRun) tea.Cmd {
372+
return f.runList(ctx, &workflowviews.TaskRunListInput{TaskSlug: t.Id}, func(tr *workflows.TaskRun) tea.Cmd {
373373
input.TaskRunID = tr.Id
374374
return f.runDetails(ctx, input)
375375
})

pkg/tui/views/workflows/loader.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (t *WorkflowLoader) CreateTaskRun(ctx context.Context, input TaskRunInput)
6666
if err != nil {
6767
return nil, err
6868
}
69-
return t.taskRepo.RunTask(ctx, input.TaskID, inputData)
69+
return t.taskRepo.RunTask(ctx, input.TaskSlug, inputData)
7070
}
7171

7272
func unmarshalInputData(input string) (*workflows.TaskData, error) {
@@ -276,8 +276,8 @@ func (w *WorkflowLoader) GetTask(ctx context.Context, id string) (*wfclient.Task
276276
func (w *WorkflowLoader) LoadTaskRunList(ctx context.Context, input TaskRunListInput, cur client.Cursor) (client.Cursor, []*wfclient.TaskRun, error) {
277277
pageSize := 20
278278
params := &client.ListTaskRunsParams{Limit: &pageSize}
279-
if input.TaskID != "" {
280-
params.TaskId = pointers.From([]string{input.TaskID})
279+
if input.TaskSlug != "" {
280+
params.TaskSlug = pointers.From([]string{input.TaskSlug})
281281
}
282282
if cur != "" {
283283
params.Cursor = &cur
@@ -316,8 +316,8 @@ func (w *WorkflowLoader) LoadAllTasks(ctx context.Context, input TaskListInput)
316316
func (w *WorkflowLoader) LoadAllTaskRuns(ctx context.Context, input TaskRunListInput) ([]*wfclient.TaskRun, error) {
317317
pageSize := 100
318318
params := &client.ListTaskRunsParams{Limit: &pageSize}
319-
if input.TaskID != "" {
320-
params.TaskId = pointers.From([]string{input.TaskID})
319+
if input.TaskSlug != "" {
320+
params.TaskSlug = pointers.From([]string{input.TaskSlug})
321321
}
322322

323323
_, taskRuns, err := w.taskRepo.ListTaskRuns(ctx, params)

pkg/tui/views/workflows/types.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ type TaskListInput struct {
1515
}
1616

1717
type TaskRunInput struct {
18-
TaskID string `cli:"arg:0"`
19-
Input string `cli:"input"`
18+
TaskSlug string `cli:"arg:0"`
19+
Input string `cli:"input"`
2020
}
2121

2222
type TaskRunDetailsInput struct {
@@ -28,8 +28,8 @@ type VersionListInput struct {
2828
}
2929

3030
type TaskRunListInput struct {
31-
TaskID string `cli:"arg:0"`
32-
Local bool
31+
TaskSlug string `cli:"arg:0"`
32+
Local bool
3333
}
3434

3535
type VersionReleaseInput struct {
@@ -49,15 +49,15 @@ func (t TaskListInput) Validate(interactive bool) error {
4949
}
5050

5151
func (t TaskRunListInput) Validate(interactive bool) error {
52-
if !interactive && !t.Local && t.TaskID == "" {
53-
return errors.New("task id must be specified when output is not interactive")
52+
if !interactive && !t.Local && t.TaskSlug == "" {
53+
return errors.New("task slug must be specified when output is not interactive")
5454
}
5555
return nil
5656
}
5757

5858
func (t TaskRunInput) Validate(interactive bool) error {
59-
if !interactive && t.TaskID == "" {
60-
return errors.New("task id must be specified when output is not interactive")
59+
if !interactive && t.TaskSlug == "" {
60+
return errors.New("task slug must be specified when output is not interactive")
6161
}
6262

6363
if !interactive && t.Input == "" {

pkg/tui/views/workflows/types_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,63 +39,63 @@ func TestTaskListInputValidate(t *testing.T) {
3939
}
4040

4141
func TestTaskRunInputValidate(t *testing.T) {
42-
t.Run("non-interactive missing task ID", func(t *testing.T) {
42+
t.Run("non-interactive missing task slug", func(t *testing.T) {
4343
input := TaskRunInput{Input: `["a"]`}
4444
err := input.Validate(false)
4545
require.Error(t, err)
46-
assert.Contains(t, err.Error(), "task id must be specified")
46+
assert.Contains(t, err.Error(), "task slug must be specified")
4747
})
4848

4949
t.Run("non-interactive missing input", func(t *testing.T) {
50-
input := TaskRunInput{TaskID: "tsk-1"}
50+
input := TaskRunInput{TaskSlug: "tsk-1"}
5151
err := input.Validate(false)
5252
require.Error(t, err)
5353
assert.Contains(t, err.Error(), "input must be specified")
5454
})
5555

5656
t.Run("invalid JSON input errors even in interactive mode", func(t *testing.T) {
57-
input := TaskRunInput{TaskID: "tsk-1", Input: "not-json"}
57+
input := TaskRunInput{TaskSlug: "tsk-1", Input: "not-json"}
5858
err := input.Validate(true)
5959
require.Error(t, err)
6060
assert.Contains(t, err.Error(), "input must be valid JSON")
6161
})
6262

6363
t.Run("valid array JSON", func(t *testing.T) {
64-
input := TaskRunInput{TaskID: "tsk-1", Input: `["a","b"]`}
64+
input := TaskRunInput{TaskSlug: "tsk-1", Input: `["a","b"]`}
6565
assert.NoError(t, input.Validate(false))
6666
})
6767

6868
t.Run("valid object JSON", func(t *testing.T) {
69-
input := TaskRunInput{TaskID: "tsk-1", Input: `{"k":"v"}`}
69+
input := TaskRunInput{TaskSlug: "tsk-1", Input: `{"k":"v"}`}
7070
assert.NoError(t, input.Validate(false))
7171
})
7272
}
7373

7474
func TestTaskRunListInputValidate(t *testing.T) {
75-
t.Run("interactive allows empty task ID", func(t *testing.T) {
75+
t.Run("interactive allows empty task slug", func(t *testing.T) {
7676
input := TaskRunListInput{}
7777
assert.NoError(t, input.Validate(true))
7878
})
7979

80-
t.Run("non-interactive requires task ID", func(t *testing.T) {
80+
t.Run("non-interactive requires task slug", func(t *testing.T) {
8181
input := TaskRunListInput{}
8282
err := input.Validate(false)
8383
require.Error(t, err)
84-
assert.Contains(t, err.Error(), "task id must be specified")
84+
assert.Contains(t, err.Error(), "task slug must be specified")
8585
})
8686

87-
t.Run("non-interactive with task ID succeeds", func(t *testing.T) {
88-
input := TaskRunListInput{TaskID: "tsk-1"}
87+
t.Run("non-interactive with task slug succeeds", func(t *testing.T) {
88+
input := TaskRunListInput{TaskSlug: "tsk-1"}
8989
assert.NoError(t, input.Validate(false))
9090
})
9191

92-
t.Run("non-interactive local allows empty task ID", func(t *testing.T) {
92+
t.Run("non-interactive local allows empty task slug", func(t *testing.T) {
9393
input := TaskRunListInput{Local: true}
9494
assert.NoError(t, input.Validate(false))
9595
})
9696

97-
t.Run("non-interactive local with task ID succeeds", func(t *testing.T) {
98-
input := TaskRunListInput{TaskID: "tsk-1", Local: true}
97+
t.Run("non-interactive local with task slug succeeds", func(t *testing.T) {
98+
input := TaskRunListInput{TaskSlug: "tsk-1", Local: true}
9999
assert.NoError(t, input.Validate(false))
100100
})
101101
}

0 commit comments

Comments
 (0)