Skip to content

Commit 1813a6d

Browse files
authored
feat(controlplane): add workflow description (#541)
Signed-off-by: Miguel Martinez Trivino <[email protected]>
1 parent 6bb967a commit 1813a6d

29 files changed

+693
-339
lines changed

app/cli/cmd/workflow_create.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
func newWorkflowCreateCmd() *cobra.Command {
27-
var workflowName, project, team, contract string
27+
var workflowName, description, project, team, contract string
2828
var skipRACreate bool
2929

3030
cmd := &cobra.Command{
@@ -57,7 +57,7 @@ func newWorkflowCreateCmd() *cobra.Command {
5757
}
5858

5959
opts := &action.NewWorkflowCreateOpts{
60-
Name: workflowName, Team: team, Project: project, ContractID: contract,
60+
Name: workflowName, Team: team, Project: project, ContractID: contract, Description: description,
6161
}
6262

6363
workflow, err := action.NewWorkflowCreate(actionOpts).Run(opts)
@@ -105,6 +105,7 @@ func newWorkflowCreateCmd() *cobra.Command {
105105
cmd.Flags().StringVar(&workflowName, "name", "", "workflow name")
106106
err := cmd.MarkFlagRequired("name")
107107
cobra.CheckErr(err)
108+
cmd.Flags().StringVar(&description, "description", "", "workflow description")
108109

109110
cmd.Flags().StringVar(&project, "project", "", "project name")
110111
err = cmd.MarkFlagRequired("project")

app/cli/cmd/workflow_list.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func WorkflowListTableOutput(workflows []*action.WorkflowItem) error {
5151
}
5252

5353
headerRow := table.Row{"ID", "Name", "Project", "Created At", "Runner", "Last Run status"}
54-
headerRowFull := table.Row{"ID", "Name", "Project", "Team", "Created At", "Runner", "Last Run status", "Public", "Contract ID"}
54+
headerRowFull := table.Row{"ID", "Name", "Description", "Project", "Team", "Created At", "Runner", "Last Run status", "Public", "Contract ID"}
5555

5656
t := newTableWriter()
5757
if full {
@@ -75,7 +75,7 @@ func WorkflowListTableOutput(workflows []*action.WorkflowItem) error {
7575
}
7676
} else {
7777
row = table.Row{
78-
p.ID, p.Name, p.Project, p.Team,
78+
p.ID, p.Name, p.Description, p.Project, p.Team,
7979
p.CreatedAt.Format(time.RFC822), lastRunRunner, lastRunState,
8080
p.Public, p.ContractID,
8181
}

app/cli/cmd/workflow_update.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
)
2424

2525
func newWorkflowUpdateCmd() *cobra.Command {
26-
var workflowID, name, project, team string
26+
var workflowID, name, description, project, team string
2727
var public bool
2828

2929
cmd := &cobra.Command{
@@ -44,6 +44,10 @@ func newWorkflowUpdateCmd() *cobra.Command {
4444
opts.Public = &public
4545
}
4646

47+
if cmd.Flags().Changed("description") {
48+
opts.Description = &description
49+
}
50+
4751
res, err := action.NewWorkflowUpdate(actionOpts).Run(context.Background(), workflowID, opts)
4852
if err != nil {
4953
return err
@@ -59,6 +63,7 @@ func newWorkflowUpdateCmd() *cobra.Command {
5963
cobra.CheckErr(err)
6064

6165
cmd.Flags().StringVar(&name, "name", "", "workflow name")
66+
cmd.Flags().StringVar(&description, "description", "", "workflow description")
6267
cmd.Flags().StringVar(&team, "team", "", "team name")
6368
cmd.Flags().StringVar(&project, "project", "", "project name")
6469
cmd.Flags().BoolVar(&public, "public", false, "is the workflow public")

app/cli/internal/action/workflow_create.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ func NewWorkflowCreate(cfg *ActionsOpts) *WorkflowCreate {
3030
}
3131

3232
type NewWorkflowCreateOpts struct {
33-
Name, Project, Team, ContractID string
33+
Name, Description, Project, Team, ContractID string
3434
}
3535

3636
func (action *WorkflowCreate) Run(opts *NewWorkflowCreateOpts) (*WorkflowItem, error) {
3737
client := pb.NewWorkflowServiceClient(action.cfg.CPConnection)
3838
resp, err := client.Create(context.Background(), &pb.WorkflowServiceCreateRequest{
3939
Name: opts.Name, Project: opts.Project, Team: opts.Team, SchemaId: opts.ContractID,
40+
Description: opts.Description,
4041
})
4142
if err != nil {
4243
return nil, err

app/cli/internal/action/workflow_list.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ type WorkflowList struct {
2828
}
2929

3030
type WorkflowItem struct {
31-
Name string `json:"name"`
32-
ID string `json:"id"`
33-
Team string `json:"team"`
34-
Project string `json:"project,omitempty"`
35-
CreatedAt *time.Time `json:"createdAt"`
36-
RunsCount int32 `json:"runsCount"`
37-
ContractID string `json:"contractID,omitempty"`
38-
LastRun *WorkflowRunItem `json:"lastRun,omitempty"`
31+
Name string `json:"name"`
32+
Description string `json:"description,omitempty"`
33+
ID string `json:"id"`
34+
Team string `json:"team"`
35+
Project string `json:"project,omitempty"`
36+
CreatedAt *time.Time `json:"createdAt"`
37+
RunsCount int32 `json:"runsCount"`
38+
ContractID string `json:"contractID,omitempty"`
39+
LastRun *WorkflowRunItem `json:"lastRun,omitempty"`
3940
// A public workflow means that any user can
4041
// - access to all its workflow runs
4142
// - their attestation and materials
@@ -75,9 +76,10 @@ func pbWorkflowItemToAction(wf *pb.WorkflowItem) *WorkflowItem {
7576
res := &WorkflowItem{
7677
Name: wf.Name, ID: wf.Id, CreatedAt: toTimePtr(wf.CreatedAt.AsTime()),
7778
Project: wf.Project, Team: wf.Team, RunsCount: wf.RunsCount,
78-
ContractID: wf.ContractId,
79-
LastRun: pbWorkflowRunItemToAction(wf.LastRun),
80-
Public: wf.Public,
79+
ContractID: wf.ContractId,
80+
LastRun: pbWorkflowRunItemToAction(wf.LastRun),
81+
Public: wf.Public,
82+
Description: wf.Description,
8183
}
8284

8385
return res

app/cli/internal/action/workflow_update.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,16 @@ func NewWorkflowUpdate(cfg *ActionsOpts) *WorkflowUpdate {
3030
}
3131

3232
type NewWorkflowUpdateOpts struct {
33-
Name, Project, Team *string
34-
Public *bool
33+
Name, Description, Project, Team *string
34+
Public *bool
3535
}
3636

3737
func (action *WorkflowUpdate) Run(ctx context.Context, id string, opts *NewWorkflowUpdateOpts) (*WorkflowItem, error) {
3838
client := pb.NewWorkflowServiceClient(action.cfg.CPConnection)
3939
resp, err := client.Update(ctx, &pb.WorkflowServiceUpdateRequest{
4040
Id: id,
41-
Name: opts.Name, Project: opts.Project, Team: opts.Team,
41+
Name: opts.Name, Description: opts.Description,
42+
Project: opts.Project, Team: opts.Team,
4243
Public: opts.Public,
4344
})
4445

0 commit comments

Comments
 (0)