CreateChildTask creates one child task beneath the supplied parent and emits an additional parent-scoped audit event.
( ctx context.Context, parentTaskID string, spec CreateTask, actor ActorContext, )
| 371 | // CreateChildTask creates one child task beneath the supplied parent and emits |
| 372 | // an additional parent-scoped audit event. |
| 373 | func (m *Service) CreateChildTask( |
| 374 | ctx context.Context, |
| 375 | parentTaskID string, |
| 376 | spec CreateTask, |
| 377 | actor ActorContext, |
| 378 | ) (*Task, error) { |
| 379 | trimmedParentID := strings.TrimSpace(parentTaskID) |
| 380 | if trimmedParentID == "" { |
| 381 | return nil, fmt.Errorf("%w: child parent task id is required", ErrValidation) |
| 382 | } |
| 383 | if strings.TrimSpace(spec.ParentTaskID) != "" && strings.TrimSpace(spec.ParentTaskID) != trimmedParentID { |
| 384 | return nil, fmt.Errorf("%w: create_task.parent_task_id must match child parent task id", ErrValidation) |
| 385 | } |
| 386 | |
| 387 | spec.ParentTaskID = trimmedParentID |
| 388 | child, err := m.CreateTask(ctx, spec, actor) |
| 389 | if err != nil { |
| 390 | return nil, err |
| 391 | } |
| 392 | if err := m.recordTaskEvent(ctx, trimmedParentID, "", taskEventChildCreated, actor, childCreatedTaskPayload{ |
| 393 | ChildTaskID: child.ID, |
| 394 | ChildScope: child.Scope, |
| 395 | ChildWorkspaceID: child.WorkspaceID, |
| 396 | }); err != nil { |
| 397 | return nil, err |
| 398 | } |
| 399 | return child, nil |
| 400 | } |
| 401 | |
| 402 | // DeleteTask removes one task after verifying it is not still in use by child |
| 403 | // tasks or non-terminal runs, then reconciles any dependents unblocked by the |
nothing calls this directly
no test coverage detected