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

Method Update

app/controlplane/pkg/data/workflow.go:229–264  ·  view source on GitHub ↗
(ctx context.Context, id uuid.UUID, opts *biz.WorkflowUpdateOpts)

Source from the content-addressed store, hash-verified

227}
228
229func (r *WorkflowRepo) Update(ctx context.Context, id uuid.UUID, opts *biz.WorkflowUpdateOpts) (*biz.Workflow, error) {
230 ctx, span := otelx.Start(ctx, workflowRepoTracer, "WorkflowRepo.Update")
231 defer span.End()
232
233 if opts == nil {
234 opts = &biz.WorkflowUpdateOpts{}
235 }
236
237 req := r.data.DB.Workflow.UpdateOneID(id).
238 SetNillableTeam(opts.Team).
239 SetNillablePublic(opts.Public).
240 SetNillableDescription(opts.Description).
241 SetUpdatedAt(time.Now())
242
243 // Update the contract if provided
244 if opts.ContractID != nil {
245 contractUUID, err := uuid.Parse(*opts.ContractID)
246 if err != nil {
247 return nil, err
248 }
249 req = req.SetContractID(contractUUID)
250 }
251
252 wf, err := req.Save(ctx)
253
254 if err != nil {
255 if ent.IsConstraintError(err) {
256 return nil, biz.NewErrAlreadyExists(err)
257 }
258
259 return nil, fmt.Errorf("failed to update workflow: %w", err)
260 }
261
262 // Reload the object to include the relations
263 return r.FindByID(ctx, wf.ID)
264}
265
266func (r *WorkflowRepo) List(ctx context.Context, orgID uuid.UUID, filter *biz.WorkflowListOpts, pagination *pagination.OffsetPaginationOpts) ([]*biz.Workflow, int, error) {
267 ctx, span := otelx.Start(ctx, workflowRepoTracer, "WorkflowRepo.List")

Callers

nothing calls this directly

Implementers 1

WorkflowRepoapp/controlplane/pkg/data/workflow.go

Calls 12

FindByIDMethod · 0.95
StartFunction · 0.92
IsConstraintErrorFunction · 0.92
NewErrAlreadyExistsFunction · 0.92
ParseMethod · 0.80
SaveMethod · 0.65
SetUpdatedAtMethod · 0.45
SetNillablePublicMethod · 0.45
SetNillableTeamMethod · 0.45
UpdateOneIDMethod · 0.45
SetContractIDMethod · 0.45

Tested by

no test coverage detected