mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08: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:
@@ -19,6 +19,20 @@ const (
|
||||
WorkspaceTransitionDelete WorkspaceTransition = "delete"
|
||||
)
|
||||
|
||||
type BuildReason string
|
||||
|
||||
const (
|
||||
// "initiator" is used when a workspace build is triggered by a user.
|
||||
// Combined with the initiator id/username, it indicates which user initiated the build.
|
||||
BuildReasonInitiator BuildReason = "initiator"
|
||||
// "autostart" is used when a build to start a workspace is triggered by Autostart.
|
||||
// The initiator id/username in this case is the workspace owner and can be ignored.
|
||||
BuildReasonAutostart BuildReason = "autostart"
|
||||
// "autostop" is used when a build to stop a workspace is triggered by Autostop.
|
||||
// The initiator id/username in this case is the workspace owner and can be ignored.
|
||||
BuildReasonAutostop BuildReason = "autostop"
|
||||
)
|
||||
|
||||
// WorkspaceBuild is an at-point representation of a workspace state.
|
||||
// BuildNumbers start at 1 and increase by 1 for each subsequent build
|
||||
type WorkspaceBuild struct {
|
||||
@@ -37,6 +51,7 @@ type WorkspaceBuild struct {
|
||||
InitiatorUsername string `json:"initiator_name"`
|
||||
Job ProvisionerJob `json:"job"`
|
||||
Deadline time.Time `json:"deadline"`
|
||||
Reason BuildReason `db:"reason" json:"reason"`
|
||||
}
|
||||
|
||||
// WorkspaceBuild returns a single workspace build for a workspace.
|
||||
|
||||
Reference in New Issue
Block a user