mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
feat: Extract instance type when provisioning VMs (#4839)
This should help us identify what instances our users consume.
This commit is contained in:
@ -5481,7 +5481,7 @@ func (q *sqlQuerier) UpdateWorkspaceBuildByID(ctx context.Context, arg UpdateWor
|
||||
|
||||
const getWorkspaceResourceByID = `-- name: GetWorkspaceResourceByID :one
|
||||
SELECT
|
||||
id, created_at, job_id, transition, type, name, hide, icon
|
||||
id, created_at, job_id, transition, type, name, hide, icon, instance_type
|
||||
FROM
|
||||
workspace_resources
|
||||
WHERE
|
||||
@ -5500,6 +5500,7 @@ func (q *sqlQuerier) GetWorkspaceResourceByID(ctx context.Context, id uuid.UUID)
|
||||
&i.Name,
|
||||
&i.Hide,
|
||||
&i.Icon,
|
||||
&i.InstanceType,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@ -5614,7 +5615,7 @@ func (q *sqlQuerier) GetWorkspaceResourceMetadataCreatedAfter(ctx context.Contex
|
||||
|
||||
const getWorkspaceResourcesByJobID = `-- name: GetWorkspaceResourcesByJobID :many
|
||||
SELECT
|
||||
id, created_at, job_id, transition, type, name, hide, icon
|
||||
id, created_at, job_id, transition, type, name, hide, icon, instance_type
|
||||
FROM
|
||||
workspace_resources
|
||||
WHERE
|
||||
@ -5639,6 +5640,7 @@ func (q *sqlQuerier) GetWorkspaceResourcesByJobID(ctx context.Context, jobID uui
|
||||
&i.Name,
|
||||
&i.Hide,
|
||||
&i.Icon,
|
||||
&i.InstanceType,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -5655,7 +5657,7 @@ func (q *sqlQuerier) GetWorkspaceResourcesByJobID(ctx context.Context, jobID uui
|
||||
|
||||
const getWorkspaceResourcesByJobIDs = `-- name: GetWorkspaceResourcesByJobIDs :many
|
||||
SELECT
|
||||
id, created_at, job_id, transition, type, name, hide, icon
|
||||
id, created_at, job_id, transition, type, name, hide, icon, instance_type
|
||||
FROM
|
||||
workspace_resources
|
||||
WHERE
|
||||
@ -5680,6 +5682,7 @@ func (q *sqlQuerier) GetWorkspaceResourcesByJobIDs(ctx context.Context, ids []uu
|
||||
&i.Name,
|
||||
&i.Hide,
|
||||
&i.Icon,
|
||||
&i.InstanceType,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -5695,7 +5698,7 @@ func (q *sqlQuerier) GetWorkspaceResourcesByJobIDs(ctx context.Context, ids []uu
|
||||
}
|
||||
|
||||
const getWorkspaceResourcesCreatedAfter = `-- name: GetWorkspaceResourcesCreatedAfter :many
|
||||
SELECT id, created_at, job_id, transition, type, name, hide, icon FROM workspace_resources WHERE created_at > $1
|
||||
SELECT id, created_at, job_id, transition, type, name, hide, icon, instance_type FROM workspace_resources WHERE created_at > $1
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) GetWorkspaceResourcesCreatedAfter(ctx context.Context, createdAt time.Time) ([]WorkspaceResource, error) {
|
||||
@ -5716,6 +5719,7 @@ func (q *sqlQuerier) GetWorkspaceResourcesCreatedAfter(ctx context.Context, crea
|
||||
&i.Name,
|
||||
&i.Hide,
|
||||
&i.Icon,
|
||||
&i.InstanceType,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -5732,20 +5736,21 @@ func (q *sqlQuerier) GetWorkspaceResourcesCreatedAfter(ctx context.Context, crea
|
||||
|
||||
const insertWorkspaceResource = `-- name: InsertWorkspaceResource :one
|
||||
INSERT INTO
|
||||
workspace_resources (id, created_at, job_id, transition, type, name, hide, icon)
|
||||
workspace_resources (id, created_at, job_id, transition, type, name, hide, icon, instance_type)
|
||||
VALUES
|
||||
($1, $2, $3, $4, $5, $6, $7, $8) RETURNING id, created_at, job_id, transition, type, name, hide, icon
|
||||
($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING id, created_at, job_id, transition, type, name, hide, icon, instance_type
|
||||
`
|
||||
|
||||
type InsertWorkspaceResourceParams struct {
|
||||
ID uuid.UUID `db:"id" json:"id"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
JobID uuid.UUID `db:"job_id" json:"job_id"`
|
||||
Transition WorkspaceTransition `db:"transition" json:"transition"`
|
||||
Type string `db:"type" json:"type"`
|
||||
Name string `db:"name" json:"name"`
|
||||
Hide bool `db:"hide" json:"hide"`
|
||||
Icon string `db:"icon" json:"icon"`
|
||||
ID uuid.UUID `db:"id" json:"id"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
JobID uuid.UUID `db:"job_id" json:"job_id"`
|
||||
Transition WorkspaceTransition `db:"transition" json:"transition"`
|
||||
Type string `db:"type" json:"type"`
|
||||
Name string `db:"name" json:"name"`
|
||||
Hide bool `db:"hide" json:"hide"`
|
||||
Icon string `db:"icon" json:"icon"`
|
||||
InstanceType sql.NullString `db:"instance_type" json:"instance_type"`
|
||||
}
|
||||
|
||||
func (q *sqlQuerier) InsertWorkspaceResource(ctx context.Context, arg InsertWorkspaceResourceParams) (WorkspaceResource, error) {
|
||||
@ -5758,6 +5763,7 @@ func (q *sqlQuerier) InsertWorkspaceResource(ctx context.Context, arg InsertWork
|
||||
arg.Name,
|
||||
arg.Hide,
|
||||
arg.Icon,
|
||||
arg.InstanceType,
|
||||
)
|
||||
var i WorkspaceResource
|
||||
err := row.Scan(
|
||||
@ -5769,6 +5775,7 @@ func (q *sqlQuerier) InsertWorkspaceResource(ctx context.Context, arg InsertWork
|
||||
&i.Name,
|
||||
&i.Hide,
|
||||
&i.Icon,
|
||||
&i.InstanceType,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user