feat: add exit code and status to workspace agent scripts (#24505)

For scripts that have not finished or in dry run cases these will be
omitted.
This commit is contained in:
Asher
2026-04-29 12:24:26 -08:00
committed by GitHub
parent 1c30d52b2b
commit be57af5ff0
25 changed files with 286 additions and 80 deletions
+3 -14
View File
@@ -67,7 +67,7 @@ func (api *API) workspaceAgent(rw http.ResponseWriter, r *http.Request) {
ctx = r.Context()
waws = httpmw.WorkspaceAgentAndWorkspaceParam(r)
dbApps []database.WorkspaceApp
scripts []database.WorkspaceAgentScript
scripts []database.GetWorkspaceAgentScriptsByAgentIDsRow
logSources []database.WorkspaceAgentLogSource
)
@@ -1634,21 +1634,10 @@ func convertLogSources(dbLogSources []database.WorkspaceAgentLogSource) []coders
return logSources
}
func convertScripts(dbScripts []database.WorkspaceAgentScript) []codersdk.WorkspaceAgentScript {
func convertScripts(dbScripts []database.GetWorkspaceAgentScriptsByAgentIDsRow) []codersdk.WorkspaceAgentScript {
scripts := make([]codersdk.WorkspaceAgentScript, 0)
for _, dbScript := range dbScripts {
scripts = append(scripts, codersdk.WorkspaceAgentScript{
ID: dbScript.ID,
LogPath: dbScript.LogPath,
LogSourceID: dbScript.LogSourceID,
Script: dbScript.Script,
Cron: dbScript.Cron,
RunOnStart: dbScript.RunOnStart,
RunOnStop: dbScript.RunOnStop,
StartBlocksLogin: dbScript.StartBlocksLogin,
Timeout: time.Duration(dbScript.TimeoutSeconds) * time.Second,
DisplayName: dbScript.DisplayName,
})
scripts = append(scripts, db2sdk.WorkspaceAgentScript(dbScript))
}
return scripts
}