mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
feat: allow specifying devcontainer on agent in terraform (#16997)
This change allows specifying devcontainers in terraform and plumbs it through to the agent via agent manifest. This will be used for autostarting devcontainers in a workspace. Depends on coder/terraform-provider-coder#368 Updates #16423
This commit is contained in:
committed by
GitHub
parent
287e3198d8
commit
69ba27e347
@ -237,6 +237,7 @@ type data struct {
|
||||
workspaceAgentStats []database.WorkspaceAgentStat
|
||||
workspaceAgentMemoryResourceMonitors []database.WorkspaceAgentMemoryResourceMonitor
|
||||
workspaceAgentVolumeResourceMonitors []database.WorkspaceAgentVolumeResourceMonitor
|
||||
workspaceAgentDevcontainers []database.WorkspaceAgentDevcontainer
|
||||
workspaceApps []database.WorkspaceApp
|
||||
workspaceAppAuditSessions []database.WorkspaceAppAuditSession
|
||||
workspaceAppStatsLastInsertID int64
|
||||
@ -6696,6 +6697,22 @@ func (q *FakeQuerier) GetWorkspaceAgentByInstanceID(_ context.Context, instanceI
|
||||
return database.WorkspaceAgent{}, sql.ErrNoRows
|
||||
}
|
||||
|
||||
func (q *FakeQuerier) GetWorkspaceAgentDevcontainersByAgentID(_ context.Context, workspaceAgentID uuid.UUID) ([]database.WorkspaceAgentDevcontainer, error) {
|
||||
q.mutex.RLock()
|
||||
defer q.mutex.RUnlock()
|
||||
|
||||
devcontainers := make([]database.WorkspaceAgentDevcontainer, 0)
|
||||
for _, dc := range q.workspaceAgentDevcontainers {
|
||||
if dc.WorkspaceAgentID == workspaceAgentID {
|
||||
devcontainers = append(devcontainers, dc)
|
||||
}
|
||||
}
|
||||
if len(devcontainers) == 0 {
|
||||
return nil, sql.ErrNoRows
|
||||
}
|
||||
return devcontainers, nil
|
||||
}
|
||||
|
||||
func (q *FakeQuerier) GetWorkspaceAgentLifecycleStateByID(ctx context.Context, id uuid.UUID) (database.GetWorkspaceAgentLifecycleStateByIDRow, error) {
|
||||
q.mutex.RLock()
|
||||
defer q.mutex.RUnlock()
|
||||
@ -9051,6 +9068,35 @@ func (q *FakeQuerier) InsertWorkspaceAgent(_ context.Context, arg database.Inser
|
||||
return agent, nil
|
||||
}
|
||||
|
||||
func (q *FakeQuerier) InsertWorkspaceAgentDevcontainers(_ context.Context, arg database.InsertWorkspaceAgentDevcontainersParams) ([]database.WorkspaceAgentDevcontainer, error) {
|
||||
err := validateDatabaseType(arg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
q.mutex.Lock()
|
||||
defer q.mutex.Unlock()
|
||||
|
||||
for _, agent := range q.workspaceAgents {
|
||||
if agent.ID == arg.WorkspaceAgentID {
|
||||
var devcontainers []database.WorkspaceAgentDevcontainer
|
||||
for i, id := range arg.ID {
|
||||
devcontainers = append(devcontainers, database.WorkspaceAgentDevcontainer{
|
||||
WorkspaceAgentID: arg.WorkspaceAgentID,
|
||||
CreatedAt: arg.CreatedAt,
|
||||
ID: id,
|
||||
WorkspaceFolder: arg.WorkspaceFolder[i],
|
||||
ConfigPath: arg.ConfigPath[i],
|
||||
})
|
||||
}
|
||||
q.workspaceAgentDevcontainers = append(q.workspaceAgentDevcontainers, devcontainers...)
|
||||
return devcontainers, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, errForeignKeyConstraint
|
||||
}
|
||||
|
||||
func (q *FakeQuerier) InsertWorkspaceAgentLogSources(_ context.Context, arg database.InsertWorkspaceAgentLogSourcesParams) ([]database.WorkspaceAgentLogSource, error) {
|
||||
err := validateDatabaseType(arg)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user