mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
Add reason
field for workspace builds (#2438)
* add reason field for workspace build * add the reason field to FE via API * update BuildReasonMember to BuildReasonInitiator * add unit tests * add more unit tests * add error for unknown transition * fix lint * add documentation * fix unit tests * fix generated types * remove nested transaction * rename migration file
This commit is contained in:
@ -209,6 +209,17 @@ func build(ctx context.Context, store database.Store, workspace database.Workspa
|
||||
}
|
||||
provisionerJobID := uuid.New()
|
||||
now := database.Now()
|
||||
|
||||
var buildReason database.BuildReason
|
||||
switch trans {
|
||||
case database.WorkspaceTransitionStart:
|
||||
buildReason = database.BuildReasonAutostart
|
||||
case database.WorkspaceTransitionStop:
|
||||
buildReason = database.BuildReasonAutostop
|
||||
default:
|
||||
return xerrors.Errorf("Unsupported transition: %q", trans)
|
||||
}
|
||||
|
||||
newProvisionerJob, err := store.InsertProvisionerJob(ctx, database.InsertProvisionerJobParams{
|
||||
ID: provisionerJobID,
|
||||
CreatedAt: now,
|
||||
@ -236,6 +247,7 @@ func build(ctx context.Context, store database.Store, workspace database.Workspa
|
||||
InitiatorID: workspace.OwnerID,
|
||||
Transition: trans,
|
||||
JobID: newProvisionerJob.ID,
|
||||
Reason: buildReason,
|
||||
})
|
||||
if err != nil {
|
||||
return xerrors.Errorf("insert workspace build: %w", err)
|
||||
|
Reference in New Issue
Block a user