Skip to content

Commit 41ce282

Browse files
authored
feat(workflows): Remove the option of updating the workflow name (#921)
Signed-off-by: Javier Rodriguez <[email protected]>
1 parent 9449f4f commit 41ce282

File tree

11 files changed

+121
-198
lines changed

11 files changed

+121
-198
lines changed

app/cli/cmd/workflow_update.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,14 @@ import (
2323
)
2424

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

2929
cmd := &cobra.Command{
3030
Use: "update",
3131
Short: "Update an existing workflow",
3232
RunE: func(cmd *cobra.Command, args []string) error {
33-
opts := &action.NewWorkflowUpdateOpts{}
34-
if cmd.Flags().Changed("name") {
35-
opts.Name = &name
36-
}
33+
opts := &action.WorkflowUpdateOpts{}
3734
if cmd.Flags().Changed("team") {
3835
opts.Team = &team
3936
}
@@ -66,7 +63,6 @@ func newWorkflowUpdateCmd() *cobra.Command {
6663
err := cmd.MarkFlagRequired("id")
6764
cobra.CheckErr(err)
6865

69-
cmd.Flags().StringVar(&name, "name", "", "workflow name")
7066
cmd.Flags().StringVar(&description, "description", "", "workflow description")
7167
cmd.Flags().StringVar(&team, "team", "", "team name")
7268
cmd.Flags().StringVar(&project, "project", "", "project name")

app/cli/internal/action/workflow_update.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,20 @@ func NewWorkflowUpdate(cfg *ActionsOpts) *WorkflowUpdate {
2929
return &WorkflowUpdate{cfg}
3030
}
3131

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

37-
func (action *WorkflowUpdate) Run(ctx context.Context, id string, opts *NewWorkflowUpdateOpts) (*WorkflowItem, error) {
37+
func (action *WorkflowUpdate) Run(ctx context.Context, id string, opts *WorkflowUpdateOpts) (*WorkflowItem, error) {
3838
client := pb.NewWorkflowServiceClient(action.cfg.CPConnection)
3939
resp, err := client.Update(ctx, &pb.WorkflowServiceUpdateRequest{
40-
Id: id,
41-
Name: opts.Name, Description: opts.Description,
42-
Project: opts.Project, Team: opts.Team,
43-
Public: opts.Public,
44-
SchemaId: opts.ContractID,
40+
Id: id,
41+
Description: opts.Description,
42+
Project: opts.Project,
43+
Team: opts.Team,
44+
Public: opts.Public,
45+
SchemaId: opts.ContractID,
4546
})
4647

4748
if err != nil {

app/controlplane/api/controlplane/v1/workflow.pb.go

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

app/controlplane/api/controlplane/v1/workflow.proto

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ message WorkflowServiceUpdateRequest {
4444
string id = 1 [(buf.validate.field).string.uuid = true];
4545
// "optional" allow us to detect if the value is explicitly set
4646
// and not just the default value
47-
optional string name = 2;
4847
optional string project = 3;
4948
optional string team = 4;
5049
optional bool public = 5;

app/controlplane/api/gen/frontend/controlplane/v1/workflow.ts

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

app/controlplane/internal/biz/workflow.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ type WorkflowCreateOpts struct {
5959
}
6060

6161
type WorkflowUpdateOpts struct {
62-
Name, Project, Team, Description, ContractID *string
63-
Public *bool
62+
Project, Team, Description, ContractID *string
63+
Public *bool
6464
}
6565

6666
type WorkflowUseCase struct {
@@ -125,13 +125,6 @@ func (uc *WorkflowUseCase) Update(ctx context.Context, orgID, workflowID string,
125125
return nil, NewErrInvalidUUID(err)
126126
}
127127

128-
if opts.Name != nil {
129-
// validate format of the name and the project
130-
if err := ValidateIsDNS1123(*opts.Name); err != nil {
131-
return nil, NewErrValidation(err)
132-
}
133-
}
134-
135128
if opts.Project != nil && *opts.Project != "" {
136129
if err := ValidateIsDNS1123(*opts.Project); err != nil {
137130
return nil, NewErrValidation(err)

app/controlplane/internal/biz/workflow_integration_test.go

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func (s *workflowIntegrationTestSuite) TestUpdate() {
200200
})
201201

202202
s.Run("can't update a workflow in another org", func() {
203-
got, err := s.Workflow.Update(ctx, org2.ID, workflow.ID.String(), &biz.WorkflowUpdateOpts{Name: toPtrS("new-name")})
203+
got, err := s.Workflow.Update(ctx, org2.ID, workflow.ID.String(), &biz.WorkflowUpdateOpts{Description: toPtrS("new description")})
204204
s.True(biz.IsNotFound(err))
205205
s.Error(err)
206206
s.Nil(got)
@@ -218,37 +218,26 @@ func (s *workflowIntegrationTestSuite) TestUpdate() {
218218
{
219219
name: "non existing workflow",
220220
id: uuid.Generate().String(),
221-
updates: &biz.WorkflowUpdateOpts{Name: toPtrS("new-name")},
221+
updates: &biz.WorkflowUpdateOpts{Description: toPtrS("new description")},
222222
wantErr: true,
223223
},
224224
{
225225
name: "invalid uuid",
226226
id: "deadbeef",
227-
updates: &biz.WorkflowUpdateOpts{Name: toPtrS("new-name")},
227+
updates: &biz.WorkflowUpdateOpts{Description: toPtrS("new description")},
228228
wantErr: true,
229229
},
230230
{
231231
name: "no updates",
232232
wantErr: true,
233233
wantErrMsg: "no updates provided",
234234
},
235-
{
236-
name: "invalid name",
237-
wantErr: true,
238-
wantErrMsg: "RFC 1123",
239-
updates: &biz.WorkflowUpdateOpts{Name: toPtrS(" no no ")},
240-
},
241235
{
242236
name: "invalid Project",
243237
wantErr: true,
244238
wantErrMsg: "RFC 1123",
245239
updates: &biz.WorkflowUpdateOpts{Project: toPtrS(" no no ")},
246240
},
247-
{
248-
name: "update name",
249-
updates: &biz.WorkflowUpdateOpts{Name: toPtrS("new-name")},
250-
want: &biz.Workflow{Name: "new-name", Description: description, Team: team, Project: project, Public: false},
251-
},
252241
{
253242
name: "update description",
254243
updates: &biz.WorkflowUpdateOpts{Description: toPtrS("new description")},
@@ -261,13 +250,8 @@ func (s *workflowIntegrationTestSuite) TestUpdate() {
261250
},
262251
{
263252
name: "update all options",
264-
updates: &biz.WorkflowUpdateOpts{Name: toPtrS("new-name-2"), Project: toPtrS("new-project"), Team: toPtrS("new team"), Public: toPtrBool(true)},
265-
want: &biz.Workflow{Name: "new-name-2", Description: description, Team: "new team", Project: "new-project", Public: true},
266-
},
267-
{
268-
name: "name can't be emptied",
269-
updates: &biz.WorkflowUpdateOpts{Name: toPtrS("")},
270-
wantErr: true,
253+
updates: &biz.WorkflowUpdateOpts{Project: toPtrS("new-project"), Team: toPtrS("new team"), Public: toPtrBool(true)},
254+
want: &biz.Workflow{Description: description, Team: "new team", Project: "new-project", Public: true},
271255
},
272256
{
273257
name: "can update contract",

app/controlplane/internal/data/ent/schema/workflow.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type Workflow struct {
3434
// Fields of the Workflow.
3535
func (Workflow) Fields() []ent.Field {
3636
return []ent.Field{
37-
field.String("name"),
37+
field.String("name").Immutable(),
3838
field.String("project").Optional(),
3939
field.String("team").Optional(),
4040
field.Int("runs_count").Default(0),

app/controlplane/internal/data/ent/workflow_update.go

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

app/controlplane/internal/data/workflow.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,6 @@ func (r *WorkflowRepo) Update(ctx context.Context, id uuid.UUID, opts *biz.Workf
8686
SetNillablePublic(opts.Public).
8787
SetNillableDescription(opts.Description)
8888

89-
// Required schema properties do not have a nillable setter
90-
// https://github.com/ent/ent/issues/2108#issuecomment-961898661
91-
if opts.Name != nil && *opts.Name != "" {
92-
req = req.SetName(*opts.Name)
93-
}
94-
9589
// Update the contract if provided
9690
if opts.ContractID != nil {
9791
contractUUID, err := uuid.Parse(*opts.ContractID)

0 commit comments

Comments
 (0)