Skip to content
Prev Previous commit
Next Next commit
add the reason field to FE via API
  • Loading branch information
AbhineetJain committed Jun 17, 2022
commit d4606174b581a91eb72b39d92b3f8d592db0f96b
9 changes: 9 additions & 0 deletions codersdk/workspacebuilds.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ const (
WorkspaceTransitionDelete WorkspaceTransition = "delete"
)

type BuildReason string

const (
BuildReasonMember BuildReason = "member"
BuildReasonAutostart BuildReason = "autostart"
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 {
Expand All @@ -37,6 +45,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.
Expand Down
6 changes: 5 additions & 1 deletion site/src/api/typesGenerated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ export interface WorkspaceApp {
readonly icon?: string
}

// From codersdk/workspacebuilds.go:24:6
// From codersdk/workspacebuilds.go:32:6
export interface WorkspaceBuild {
readonly id: string
readonly created_at: string
Expand All @@ -460,6 +460,7 @@ export interface WorkspaceBuild {
readonly initiator_name: string
readonly job: ProvisionerJob
readonly deadline: string
readonly reason: BuildReason
}

// From codersdk/workspaces.go:84:6
Expand Down Expand Up @@ -488,6 +489,9 @@ export interface WorkspaceResource {
readonly agents?: WorkspaceAgent[]
}

// From codersdk/workspacebuilds.go:22:6
export type BuildReason = "autostart" | "autostop" | "member"

// From codersdk/provisionerdaemons.go:23:6
export type LogLevel = "debug" | "error" | "info" | "trace" | "warn"

Expand Down
5 changes: 3 additions & 2 deletions site/src/testHelpers/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ export const MockWorkspaceBuild: TypesGen.WorkspaceBuild = {
build_number: 1,
created_at: "2022-05-17T17:39:01.382927298Z",
id: "1",
initiator_id: "",
initiator_name: "",
initiator_id: MockUser.id,
initiator_name: MockUser.username,
job: MockProvisionerJob,
name: "a-workspace-build",
template_version_id: "",
Expand All @@ -156,6 +156,7 @@ export const MockWorkspaceBuild: TypesGen.WorkspaceBuild = {
workspace_owner_name: MockUser.username,
workspace_id: "759f1d46-3174-453d-aa60-980a9c1442f3",
deadline: "2022-05-17T23:39:00.00Z",
reason: "member",
}

export const MockWorkspaceBuildStop: TypesGen.WorkspaceBuild = {
Expand Down