mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user