MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / Update

Method Update

app/controlplane/pkg/data/group.go:369–396  ·  view source on GitHub ↗

Update updates an existing group in the specified organization.

(ctx context.Context, orgID uuid.UUID, groupID uuid.UUID, opts *biz.UpdateGroupOpts)

Source from the content-addressed store, hash-verified

367
368// Update updates an existing group in the specified organization.
369func (g GroupRepo) Update(ctx context.Context, orgID uuid.UUID, groupID uuid.UUID, opts *biz.UpdateGroupOpts) (*biz.Group, error) {
370 ctx, span := otelx.Start(ctx, groupRepoTracer, "GroupRepo.Update")
371 defer span.End()
372
373 if opts == nil {
374 return nil, biz.NewErrValidationStr("update group options cannot be nil")
375 }
376
377 // Update the group with the provided options
378 entGroup, err := g.data.DB.Group.UpdateOneID(groupID).
379 SetNillableName(opts.NewName).
380 SetNillableDescription(opts.NewDescription).
381 SetUpdatedAt(time.Now()).
382 Where(group.OrganizationIDEQ(orgID), group.DeletedAtIsNil()).
383 Save(ctx)
384 if err != nil {
385 if ent.IsNotFound(err) {
386 return nil, biz.NewErrNotFound("group")
387 }
388 if ent.IsConstraintError(err) {
389 return nil, biz.NewErrAlreadyExistsStr("group with the same name already exists")
390 }
391
392 return nil, err
393 }
394
395 return g.FindByOrgAndID(ctx, orgID, entGroup.ID)
396}
397
398// SoftDelete soft-deletes a group by setting the DeletedAt field to the current time.
399// It also marks all group memberships as deleted and removes any pending invitations related to the group.

Callers

nothing calls this directly

Implementers 1

GroupRepoapp/controlplane/pkg/data/group.go

Calls 15

FindByOrgAndIDMethod · 0.95
StartFunction · 0.92
NewErrValidationStrFunction · 0.92
OrganizationIDEQFunction · 0.92
DeletedAtIsNilFunction · 0.92
IsNotFoundFunction · 0.92
NewErrNotFoundFunction · 0.92
IsConstraintErrorFunction · 0.92
NewErrAlreadyExistsStrFunction · 0.92
SaveMethod · 0.65
WhereMethod · 0.45
SetUpdatedAtMethod · 0.45

Tested by

no test coverage detected