mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
* feat: Add history middleware parameters These will be used for streaming logs, checking status, and other operations related to workspace and project history. * refactor: Move all HTTP routes to top-level struct Nesting all structs behind their respective structures is leaky, and promotes naming conflicts between handlers. Our HTTP routes cannot have conflicts, so neither should function naming. * Add provisioner daemon routes * Add periodic updates * Skip pubsub if short * Return jobs with WorkspaceHistory * Add endpoints for extracting singular history * The full end-to-end operation works * fix: Disable compression for websocket dRPC transport (#145) There is a race condition in the interop between the websocket and `dRPC`: https://github.com/coder/coder/runs/5038545709?check_suite_focus=true#step:7:117 - it seems both the websocket and dRPC feel like they own the `byte[]` being sent between them. This can lead to data races, in which both `dRPC` and the websocket are writing. This is just tracking some experimentation to fix that race condition ## Run results: ## - Run 1: peer test failure - Run 2: peer test failure - Run 3: `TestWorkspaceHistory/CreateHistory` - https://github.com/coder/coder/runs/5040858460?check_suite_focus=true#step:8:45 ``` status code 412: The provided project history is running. Wait for it to complete importing!` ``` - Run 4: `TestWorkspaceHistory/CreateHistory` - https://github.com/coder/coder/runs/5040957999?check_suite_focus=true#step:7:176 ``` workspacehistory_test.go:122: Error Trace: workspacehistory_test.go:122 Error: Condition never satisfied Test: TestWorkspaceHistory/CreateHistory ``` - Run 5: peer failure - Run 6: Pass ✅ - Run 7: Peer failure ## Open Questions: ## ### Is `dRPC` or `websocket` at fault for the data race? It looks like this condition is specifically happening when `dRPC` decides to [`SendError`]). This constructs a new byte payload from [`MarshalError`](f6e369438f/drpcwire/error.go (L15)
) - so `dRPC` has created this buffer and owns it. From `dRPC`'s perspective, the callstack looks like this: - [`sendPacket`](f6e369438f/drpcstream/stream.go (L253)
) - [`writeFrame`](f6e369438f/drpcwire/writer.go (L65)
) - [`AppendFrame`](f6e369438f/drpcwire/packet.go (L128)
) - with finally the data race happening here: ```go // AppendFrame appends a marshaled form of the frame to the provided buffer. func AppendFrame(buf []byte, fr Frame) []byte { ... out := buf out = append(out, control). // <--------- ``` This should be fine, since `dPRC` create this buffer, and is taking the byte buffer constructed from `MarshalError` and tacking a bunch of headers on it to create a proper frame. Once `dRPC` is done writing, it _hangs onto the buffer and resets it here__:f6e369438f/drpcwire/writer.go (L73)
However... the websocket implementation, once it gets the buffer, it runs a `statelessDeflate` [here](8dee580a7f/write.go (L180)
), which compresses the buffer on the fly. This functionality actually [mutates the buffer in place](a1a9cfc821/flate/stateless.go (L94)
), which is where get our race. In the case where the `byte[]` aren't being manipulated anywhere else, this compress-in-place operation would be safe, and that's probably the case for most over-the-wire usages. In this case, though, where we're plumbing `dRPC` -> websocket, they both are manipulating it (`dRPC` is reusing the buffer for the next `write`, and `websocket` is compressing on the fly). ### Why does cloning on `Read` fail? Get a bunch of errors like: ``` 2022/02/02 19:26:10 [WARN] yamux: frame for missing stream: Vsn:0 Type:0 Flags:0 StreamID:0 Length:0 2022/02/02 19:26:25 [ERR] yamux: Failed to read header: unexpected EOF 2022/02/02 19:26:25 [ERR] yamux: Failed to read header: unexpected EOF 2022/02/02 19:26:25 [WARN] yamux: frame for missing stream: Vsn:0 Type:0 Flags:0 StreamID:0 Length:0 ``` # UPDATE: We decided we could disable websocket compression, which would avoid the race because the in-place `deflate` operaton would no longer be run. Trying that out now: - Run 1: ✅ - Run 2: https://github.com/coder/coder/runs/5042645522?check_suite_focus=true#step:8:338 - Run 3: ✅ - Run 4: https://github.com/coder/coder/runs/5042988758?check_suite_focus=true#step:7:168 - Run 5: ✅ * fix: Remove race condition with acquiredJobDone channel (#148) Found another data race while running the tests: https://github.com/coder/coder/runs/5044320845?check_suite_focus=true#step:7:83 __Issue:__ There is a race in the p.acquiredJobDone chan - in particular, there can be a case where we're waiting on the channel to finish (in close) with <-p.acquiredJobDone, but in parallel, an acquireJob could've been started, which would create a new channel for p.acquiredJobDone. There is a similar race in `close(..)`ing the channel, which also came up in test runs. __Fix:__ Instead of recreating the channel everytime, we can use `sync.WaitGroup` to accomplish the same functionality - a semaphore to make close wait for the current job to wrap up. * fix: Bump up workspace history timeout (#149) This is an attempted fix for failures like: https://github.com/coder/coder/runs/5043435263?check_suite_focus=true#step:7:32 Looking at the timing of the test: ``` t.go:56: 2022-02-02 21:33:21.964 [DEBUG] (terraform-provisioner) <provision.go:139> ran apply t.go:56: 2022-02-02 21:33:21.991 [DEBUG] (provisionerd) <provisionerd.go:162> skipping acquire; job is already running t.go:56: 2022-02-02 21:33:22.050 [DEBUG] (provisionerd) <provisionerd.go:162> skipping acquire; job is already running t.go:56: 2022-02-02 21:33:22.090 [DEBUG] (provisionerd) <provisionerd.go:162> skipping acquire; job is already running t.go:56: 2022-02-02 21:33:22.140 [DEBUG] (provisionerd) <provisionerd.go:162> skipping acquire; job is already running t.go:56: 2022-02-02 21:33:22.195 [DEBUG] (provisionerd) <provisionerd.go:162> skipping acquire; job is already running t.go:56: 2022-02-02 21:33:22.240 [DEBUG] (provisionerd) <provisionerd.go:162> skipping acquire; job is already running workspacehistory_test.go:122: Error Trace: workspacehistory_test.go:122 Error: Condition never satisfied Test: TestWorkspaceHistory/CreateHistory ``` It appears that the `terraform apply` job had just finished - with less than a second to spare until our `require.Eventually` completes - but there's still work to be done (ie, collecting the state files). So my suspicion is that terraform might, in some cases, exceed our 5s timeout. Note that in the setup for this test - there is a similar project history wait that waits for 15s, so I borrowed that here. In the future - we can look at potentially using a simple echo provider to exercise this in the unit test, in a way that is more reliable in terms of timing. I'll log an issue to track that. Co-authored-by: Bryan <bryan@coder.com>
454 lines
17 KiB
Go
454 lines
17 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
|
|
package database
|
|
|
|
import (
|
|
"database/sql"
|
|
"encoding/json"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type LogLevel string
|
|
|
|
const (
|
|
LogLevelTrace LogLevel = "trace"
|
|
LogLevelDebug LogLevel = "debug"
|
|
LogLevelInfo LogLevel = "info"
|
|
LogLevelWarn LogLevel = "warn"
|
|
LogLevelError LogLevel = "error"
|
|
)
|
|
|
|
func (e *LogLevel) Scan(src interface{}) error {
|
|
switch s := src.(type) {
|
|
case []byte:
|
|
*e = LogLevel(s)
|
|
case string:
|
|
*e = LogLevel(s)
|
|
default:
|
|
return fmt.Errorf("unsupported scan type for LogLevel: %T", src)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type LogSource string
|
|
|
|
const (
|
|
LogSourceProvisionerDaemon LogSource = "provisioner_daemon"
|
|
LogSourceProvisioner LogSource = "provisioner"
|
|
)
|
|
|
|
func (e *LogSource) Scan(src interface{}) error {
|
|
switch s := src.(type) {
|
|
case []byte:
|
|
*e = LogSource(s)
|
|
case string:
|
|
*e = LogSource(s)
|
|
default:
|
|
return fmt.Errorf("unsupported scan type for LogSource: %T", src)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type LoginType string
|
|
|
|
const (
|
|
LoginTypeBuiltIn LoginType = "built-in"
|
|
LoginTypeSaml LoginType = "saml"
|
|
LoginTypeOIDC LoginType = "oidc"
|
|
)
|
|
|
|
func (e *LoginType) Scan(src interface{}) error {
|
|
switch s := src.(type) {
|
|
case []byte:
|
|
*e = LoginType(s)
|
|
case string:
|
|
*e = LoginType(s)
|
|
default:
|
|
return fmt.Errorf("unsupported scan type for LoginType: %T", src)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type ParameterDestinationScheme string
|
|
|
|
const (
|
|
ParameterDestinationSchemeEnvironmentVariable ParameterDestinationScheme = "environment_variable"
|
|
ParameterDestinationSchemeProvisionerVariable ParameterDestinationScheme = "provisioner_variable"
|
|
)
|
|
|
|
func (e *ParameterDestinationScheme) Scan(src interface{}) error {
|
|
switch s := src.(type) {
|
|
case []byte:
|
|
*e = ParameterDestinationScheme(s)
|
|
case string:
|
|
*e = ParameterDestinationScheme(s)
|
|
default:
|
|
return fmt.Errorf("unsupported scan type for ParameterDestinationScheme: %T", src)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type ParameterScope string
|
|
|
|
const (
|
|
ParameterScopeOrganization ParameterScope = "organization"
|
|
ParameterScopeProject ParameterScope = "project"
|
|
ParameterScopeUser ParameterScope = "user"
|
|
ParameterScopeWorkspace ParameterScope = "workspace"
|
|
)
|
|
|
|
func (e *ParameterScope) Scan(src interface{}) error {
|
|
switch s := src.(type) {
|
|
case []byte:
|
|
*e = ParameterScope(s)
|
|
case string:
|
|
*e = ParameterScope(s)
|
|
default:
|
|
return fmt.Errorf("unsupported scan type for ParameterScope: %T", src)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type ParameterSourceScheme string
|
|
|
|
const (
|
|
ParameterSourceSchemeData ParameterSourceScheme = "data"
|
|
)
|
|
|
|
func (e *ParameterSourceScheme) Scan(src interface{}) error {
|
|
switch s := src.(type) {
|
|
case []byte:
|
|
*e = ParameterSourceScheme(s)
|
|
case string:
|
|
*e = ParameterSourceScheme(s)
|
|
default:
|
|
return fmt.Errorf("unsupported scan type for ParameterSourceScheme: %T", src)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type ParameterTypeSystem string
|
|
|
|
const (
|
|
ParameterTypeSystemHCL ParameterTypeSystem = "hcl"
|
|
)
|
|
|
|
func (e *ParameterTypeSystem) Scan(src interface{}) error {
|
|
switch s := src.(type) {
|
|
case []byte:
|
|
*e = ParameterTypeSystem(s)
|
|
case string:
|
|
*e = ParameterTypeSystem(s)
|
|
default:
|
|
return fmt.Errorf("unsupported scan type for ParameterTypeSystem: %T", src)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type ProjectStorageMethod string
|
|
|
|
const (
|
|
ProjectStorageMethodInlineArchive ProjectStorageMethod = "inline-archive"
|
|
)
|
|
|
|
func (e *ProjectStorageMethod) Scan(src interface{}) error {
|
|
switch s := src.(type) {
|
|
case []byte:
|
|
*e = ProjectStorageMethod(s)
|
|
case string:
|
|
*e = ProjectStorageMethod(s)
|
|
default:
|
|
return fmt.Errorf("unsupported scan type for ProjectStorageMethod: %T", src)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type ProvisionerJobType string
|
|
|
|
const (
|
|
ProvisionerJobTypeProjectImport ProvisionerJobType = "project_import"
|
|
ProvisionerJobTypeWorkspaceProvision ProvisionerJobType = "workspace_provision"
|
|
)
|
|
|
|
func (e *ProvisionerJobType) Scan(src interface{}) error {
|
|
switch s := src.(type) {
|
|
case []byte:
|
|
*e = ProvisionerJobType(s)
|
|
case string:
|
|
*e = ProvisionerJobType(s)
|
|
default:
|
|
return fmt.Errorf("unsupported scan type for ProvisionerJobType: %T", src)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type ProvisionerType string
|
|
|
|
const (
|
|
ProvisionerTypeTerraform ProvisionerType = "terraform"
|
|
ProvisionerTypeCdrBasic ProvisionerType = "cdr-basic"
|
|
)
|
|
|
|
func (e *ProvisionerType) Scan(src interface{}) error {
|
|
switch s := src.(type) {
|
|
case []byte:
|
|
*e = ProvisionerType(s)
|
|
case string:
|
|
*e = ProvisionerType(s)
|
|
default:
|
|
return fmt.Errorf("unsupported scan type for ProvisionerType: %T", src)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type UserStatus string
|
|
|
|
const (
|
|
UserstatusActive UserStatus = "active"
|
|
UserstatusDormant UserStatus = "dormant"
|
|
UserstatusDecommissioned UserStatus = "decommissioned"
|
|
)
|
|
|
|
func (e *UserStatus) Scan(src interface{}) error {
|
|
switch s := src.(type) {
|
|
case []byte:
|
|
*e = UserStatus(s)
|
|
case string:
|
|
*e = UserStatus(s)
|
|
default:
|
|
return fmt.Errorf("unsupported scan type for UserStatus: %T", src)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type WorkspaceTransition string
|
|
|
|
const (
|
|
WorkspaceTransitionCreate WorkspaceTransition = "create"
|
|
WorkspaceTransitionStart WorkspaceTransition = "start"
|
|
WorkspaceTransitionStop WorkspaceTransition = "stop"
|
|
WorkspaceTransitionDelete WorkspaceTransition = "delete"
|
|
)
|
|
|
|
func (e *WorkspaceTransition) Scan(src interface{}) error {
|
|
switch s := src.(type) {
|
|
case []byte:
|
|
*e = WorkspaceTransition(s)
|
|
case string:
|
|
*e = WorkspaceTransition(s)
|
|
default:
|
|
return fmt.Errorf("unsupported scan type for WorkspaceTransition: %T", src)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type APIKey struct {
|
|
ID string `db:"id" json:"id"`
|
|
HashedSecret []byte `db:"hashed_secret" json:"hashed_secret"`
|
|
UserID string `db:"user_id" json:"user_id"`
|
|
Application bool `db:"application" json:"application"`
|
|
Name string `db:"name" json:"name"`
|
|
LastUsed time.Time `db:"last_used" json:"last_used"`
|
|
ExpiresAt time.Time `db:"expires_at" json:"expires_at"`
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
|
LoginType LoginType `db:"login_type" json:"login_type"`
|
|
OIDCAccessToken string `db:"oidc_access_token" json:"oidc_access_token"`
|
|
OIDCRefreshToken string `db:"oidc_refresh_token" json:"oidc_refresh_token"`
|
|
OIDCIDToken string `db:"oidc_id_token" json:"oidc_id_token"`
|
|
OIDCExpiry time.Time `db:"oidc_expiry" json:"oidc_expiry"`
|
|
DevurlToken bool `db:"devurl_token" json:"devurl_token"`
|
|
}
|
|
|
|
type License struct {
|
|
ID int32 `db:"id" json:"id"`
|
|
License json.RawMessage `db:"license" json:"license"`
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
}
|
|
|
|
type Organization struct {
|
|
ID string `db:"id" json:"id"`
|
|
Name string `db:"name" json:"name"`
|
|
Description string `db:"description" json:"description"`
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
|
Default bool `db:"default" json:"default"`
|
|
AutoOffThreshold int64 `db:"auto_off_threshold" json:"auto_off_threshold"`
|
|
CpuProvisioningRate float32 `db:"cpu_provisioning_rate" json:"cpu_provisioning_rate"`
|
|
MemoryProvisioningRate float32 `db:"memory_provisioning_rate" json:"memory_provisioning_rate"`
|
|
WorkspaceAutoOff bool `db:"workspace_auto_off" json:"workspace_auto_off"`
|
|
}
|
|
|
|
type OrganizationMember struct {
|
|
OrganizationID string `db:"organization_id" json:"organization_id"`
|
|
UserID string `db:"user_id" json:"user_id"`
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
|
Roles []string `db:"roles" json:"roles"`
|
|
}
|
|
|
|
type ParameterValue struct {
|
|
ID uuid.UUID `db:"id" json:"id"`
|
|
Name string `db:"name" json:"name"`
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
|
Scope ParameterScope `db:"scope" json:"scope"`
|
|
ScopeID string `db:"scope_id" json:"scope_id"`
|
|
SourceScheme ParameterSourceScheme `db:"source_scheme" json:"source_scheme"`
|
|
SourceValue string `db:"source_value" json:"source_value"`
|
|
DestinationScheme ParameterDestinationScheme `db:"destination_scheme" json:"destination_scheme"`
|
|
DestinationValue string `db:"destination_value" json:"destination_value"`
|
|
}
|
|
|
|
type Project struct {
|
|
ID uuid.UUID `db:"id" json:"id"`
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
|
OrganizationID string `db:"organization_id" json:"organization_id"`
|
|
Name string `db:"name" json:"name"`
|
|
Provisioner ProvisionerType `db:"provisioner" json:"provisioner"`
|
|
ActiveVersionID uuid.NullUUID `db:"active_version_id" json:"active_version_id"`
|
|
}
|
|
|
|
type ProjectHistory struct {
|
|
ID uuid.UUID `db:"id" json:"id"`
|
|
ProjectID uuid.UUID `db:"project_id" json:"project_id"`
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
|
Name string `db:"name" json:"name"`
|
|
Description string `db:"description" json:"description"`
|
|
StorageMethod ProjectStorageMethod `db:"storage_method" json:"storage_method"`
|
|
StorageSource []byte `db:"storage_source" json:"storage_source"`
|
|
ImportJobID uuid.UUID `db:"import_job_id" json:"import_job_id"`
|
|
}
|
|
|
|
type ProjectHistoryLog struct {
|
|
ID uuid.UUID `db:"id" json:"id"`
|
|
ProjectHistoryID uuid.UUID `db:"project_history_id" json:"project_history_id"`
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
Source LogSource `db:"source" json:"source"`
|
|
Level LogLevel `db:"level" json:"level"`
|
|
Output string `db:"output" json:"output"`
|
|
}
|
|
|
|
type ProjectParameter struct {
|
|
ID uuid.UUID `db:"id" json:"id"`
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
ProjectHistoryID uuid.UUID `db:"project_history_id" json:"project_history_id"`
|
|
Name string `db:"name" json:"name"`
|
|
Description string `db:"description" json:"description"`
|
|
DefaultSourceScheme ParameterSourceScheme `db:"default_source_scheme" json:"default_source_scheme"`
|
|
DefaultSourceValue sql.NullString `db:"default_source_value" json:"default_source_value"`
|
|
AllowOverrideSource bool `db:"allow_override_source" json:"allow_override_source"`
|
|
DefaultDestinationScheme ParameterDestinationScheme `db:"default_destination_scheme" json:"default_destination_scheme"`
|
|
DefaultDestinationValue sql.NullString `db:"default_destination_value" json:"default_destination_value"`
|
|
AllowOverrideDestination bool `db:"allow_override_destination" json:"allow_override_destination"`
|
|
DefaultRefresh string `db:"default_refresh" json:"default_refresh"`
|
|
RedisplayValue bool `db:"redisplay_value" json:"redisplay_value"`
|
|
ValidationError string `db:"validation_error" json:"validation_error"`
|
|
ValidationCondition string `db:"validation_condition" json:"validation_condition"`
|
|
ValidationTypeSystem ParameterTypeSystem `db:"validation_type_system" json:"validation_type_system"`
|
|
ValidationValueType string `db:"validation_value_type" json:"validation_value_type"`
|
|
}
|
|
|
|
type ProvisionerDaemon struct {
|
|
ID uuid.UUID `db:"id" json:"id"`
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
UpdatedAt sql.NullTime `db:"updated_at" json:"updated_at"`
|
|
Name string `db:"name" json:"name"`
|
|
Provisioners []ProvisionerType `db:"provisioners" json:"provisioners"`
|
|
}
|
|
|
|
type ProvisionerJob struct {
|
|
ID uuid.UUID `db:"id" json:"id"`
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
|
StartedAt sql.NullTime `db:"started_at" json:"started_at"`
|
|
CancelledAt sql.NullTime `db:"cancelled_at" json:"cancelled_at"`
|
|
CompletedAt sql.NullTime `db:"completed_at" json:"completed_at"`
|
|
Error sql.NullString `db:"error" json:"error"`
|
|
InitiatorID string `db:"initiator_id" json:"initiator_id"`
|
|
Provisioner ProvisionerType `db:"provisioner" json:"provisioner"`
|
|
Type ProvisionerJobType `db:"type" json:"type"`
|
|
ProjectID uuid.UUID `db:"project_id" json:"project_id"`
|
|
Input json.RawMessage `db:"input" json:"input"`
|
|
WorkerID uuid.NullUUID `db:"worker_id" json:"worker_id"`
|
|
}
|
|
|
|
type User struct {
|
|
ID string `db:"id" json:"id"`
|
|
Email string `db:"email" json:"email"`
|
|
Name string `db:"name" json:"name"`
|
|
Revoked bool `db:"revoked" json:"revoked"`
|
|
LoginType LoginType `db:"login_type" json:"login_type"`
|
|
HashedPassword []byte `db:"hashed_password" json:"hashed_password"`
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
|
TemporaryPassword bool `db:"temporary_password" json:"temporary_password"`
|
|
AvatarHash string `db:"avatar_hash" json:"avatar_hash"`
|
|
SshKeyRegeneratedAt time.Time `db:"ssh_key_regenerated_at" json:"ssh_key_regenerated_at"`
|
|
Username string `db:"username" json:"username"`
|
|
DotfilesGitUri string `db:"dotfiles_git_uri" json:"dotfiles_git_uri"`
|
|
Roles []string `db:"roles" json:"roles"`
|
|
Status UserStatus `db:"status" json:"status"`
|
|
Relatime time.Time `db:"relatime" json:"relatime"`
|
|
GpgKeyRegeneratedAt time.Time `db:"gpg_key_regenerated_at" json:"gpg_key_regenerated_at"`
|
|
Decomissioned bool `db:"_decomissioned" json:"_decomissioned"`
|
|
Shell string `db:"shell" json:"shell"`
|
|
}
|
|
|
|
type Workspace struct {
|
|
ID uuid.UUID `db:"id" json:"id"`
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
|
OwnerID string `db:"owner_id" json:"owner_id"`
|
|
ProjectID uuid.UUID `db:"project_id" json:"project_id"`
|
|
Name string `db:"name" json:"name"`
|
|
}
|
|
|
|
type WorkspaceAgent struct {
|
|
ID uuid.UUID `db:"id" json:"id"`
|
|
WorkspaceResourceID uuid.UUID `db:"workspace_resource_id" json:"workspace_resource_id"`
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
|
InstanceMetadata json.RawMessage `db:"instance_metadata" json:"instance_metadata"`
|
|
ResourceMetadata json.RawMessage `db:"resource_metadata" json:"resource_metadata"`
|
|
}
|
|
|
|
type WorkspaceHistory struct {
|
|
ID uuid.UUID `db:"id" json:"id"`
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
|
WorkspaceID uuid.UUID `db:"workspace_id" json:"workspace_id"`
|
|
ProjectHistoryID uuid.UUID `db:"project_history_id" json:"project_history_id"`
|
|
Name string `db:"name" json:"name"`
|
|
BeforeID uuid.NullUUID `db:"before_id" json:"before_id"`
|
|
AfterID uuid.NullUUID `db:"after_id" json:"after_id"`
|
|
Transition WorkspaceTransition `db:"transition" json:"transition"`
|
|
Initiator string `db:"initiator" json:"initiator"`
|
|
ProvisionerState []byte `db:"provisioner_state" json:"provisioner_state"`
|
|
ProvisionJobID uuid.UUID `db:"provision_job_id" json:"provision_job_id"`
|
|
}
|
|
|
|
type WorkspaceHistoryLog struct {
|
|
ID uuid.UUID `db:"id" json:"id"`
|
|
WorkspaceHistoryID uuid.UUID `db:"workspace_history_id" json:"workspace_history_id"`
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
Source LogSource `db:"source" json:"source"`
|
|
Level LogLevel `db:"level" json:"level"`
|
|
Output string `db:"output" json:"output"`
|
|
}
|
|
|
|
type WorkspaceResource struct {
|
|
ID uuid.UUID `db:"id" json:"id"`
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
WorkspaceHistoryID uuid.UUID `db:"workspace_history_id" json:"workspace_history_id"`
|
|
Type string `db:"type" json:"type"`
|
|
Name string `db:"name" json:"name"`
|
|
WorkspaceAgentToken string `db:"workspace_agent_token" json:"workspace_agent_token"`
|
|
WorkspaceAgentID uuid.NullUUID `db:"workspace_agent_id" json:"workspace_agent_id"`
|
|
}
|