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
+28
View File
@@ -675,6 +675,27 @@ func WorkspaceAgentLog(log database.WorkspaceAgentLog) codersdk.WorkspaceAgentLo
}
}
func WorkspaceAgentScript(dbScript database.GetWorkspaceAgentScriptsByAgentIDsRow) codersdk.WorkspaceAgentScript {
script := 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,
ExitCode: nullInt32Ptr(dbScript.ExitCode),
}
if dbScript.Status.Valid {
status := codersdk.WorkspaceAgentScriptStatus(dbScript.Status.WorkspaceAgentScriptTimingStatus)
script.Status = &status
}
return script
}
func ProvisionerDaemon(dbDaemon database.ProvisionerDaemon) codersdk.ProvisionerDaemon {
result := codersdk.ProvisionerDaemon{
ID: dbDaemon.ID,
@@ -1563,6 +1584,13 @@ func nullInt64Ptr(v sql.NullInt64) *int64 {
return &value
}
func nullInt32Ptr(n sql.NullInt32) *int32 {
if !n.Valid {
return nil
}
return &n.Int32
}
func nullStringPtr(v sql.NullString) *string {
if !v.Valid {
return nil