mirror of
https://github.com/coder/coder.git
synced 2025-07-06 15:41:45 +00:00
feat: add support for coder_script
(#9584)
* Add basic migrations * Improve schema * Refactor agent scripts into it's own package * Support legacy start and stop script format * Pipe the scripts! * Finish the piping * Fix context usage * It works! * Fix sql query * Fix SQL query * Rename `LogSourceID` -> `SourceID` * Fix the FE * fmt * Rename migrations * Fix log tests * Fix lint err * Fix gen * Fix story type * Rename source to script * Fix schema jank * Uncomment test * Rename proto to TimeoutSeconds * Fix comments * Fix comments * Fix legacy endpoint without specified log_source * Fix non-blocking by default in agent * Fix resources tests * Fix dbfake * Fix resources * Fix linting I think * Add fixtures * fmt * Fix startup script behavior * Fix comments * Fix context * Fix cancel * Fix SQL tests * Fix e2e tests * Interrupt on Windows * Fix agent leaking script process * Fix migrations * Fix stories * Fix duplicate logs appearing * Gen * Fix log location * Fix tests * Fix tests * Fix log output * Show display name in output * Fix print * Return timeout on start context * Gen * Fix fixture * Fix the agent status * Fix startup timeout msg * Fix command using shared context * Fix timeout draining * Change signal type * Add deterministic colors to startup script logs --------- Co-authored-by: Muhammad Atif Ali <atif@coder.com>
This commit is contained in:
@ -142,11 +142,7 @@ func WorkspaceAgent(t testing.TB, db database.Store, orig database.WorkspaceAgen
|
||||
Valid: takeFirst(orig.EnvironmentVariables.Valid, false),
|
||||
},
|
||||
OperatingSystem: takeFirst(orig.OperatingSystem, "linux"),
|
||||
StartupScript: sql.NullString{
|
||||
String: takeFirst(orig.StartupScript.String, ""),
|
||||
Valid: takeFirst(orig.StartupScript.Valid, false),
|
||||
},
|
||||
Directory: takeFirst(orig.Directory, ""),
|
||||
Directory: takeFirst(orig.Directory, ""),
|
||||
InstanceMetadata: pqtype.NullRawMessage{
|
||||
RawMessage: takeFirstSlice(orig.ResourceMetadata.RawMessage, []byte("{}")),
|
||||
Valid: takeFirst(orig.ResourceMetadata.Valid, false),
|
||||
@ -155,11 +151,9 @@ func WorkspaceAgent(t testing.TB, db database.Store, orig database.WorkspaceAgen
|
||||
RawMessage: takeFirstSlice(orig.ResourceMetadata.RawMessage, []byte("{}")),
|
||||
Valid: takeFirst(orig.ResourceMetadata.Valid, false),
|
||||
},
|
||||
ConnectionTimeoutSeconds: takeFirst(orig.ConnectionTimeoutSeconds, 3600),
|
||||
TroubleshootingURL: takeFirst(orig.TroubleshootingURL, "https://example.com"),
|
||||
MOTDFile: takeFirst(orig.TroubleshootingURL, ""),
|
||||
StartupScriptBehavior: takeFirst(orig.StartupScriptBehavior, "non-blocking"),
|
||||
StartupScriptTimeoutSeconds: takeFirst(orig.StartupScriptTimeoutSeconds, 3600),
|
||||
ConnectionTimeoutSeconds: takeFirst(orig.ConnectionTimeoutSeconds, 3600),
|
||||
TroubleshootingURL: takeFirst(orig.TroubleshootingURL, "https://example.com"),
|
||||
MOTDFile: takeFirst(orig.TroubleshootingURL, ""),
|
||||
})
|
||||
require.NoError(t, err, "insert workspace agent")
|
||||
return workspace
|
||||
@ -182,6 +176,18 @@ func Workspace(t testing.TB, db database.Store, orig database.Workspace) databas
|
||||
return workspace
|
||||
}
|
||||
|
||||
func WorkspaceAgentLogSource(t testing.TB, db database.Store, orig database.WorkspaceAgentLogSource) database.WorkspaceAgentLogSource {
|
||||
sources, err := db.InsertWorkspaceAgentLogSources(genCtx, database.InsertWorkspaceAgentLogSourcesParams{
|
||||
WorkspaceAgentID: takeFirst(orig.WorkspaceAgentID, uuid.New()),
|
||||
ID: []uuid.UUID{takeFirst(orig.ID, uuid.New())},
|
||||
CreatedAt: takeFirst(orig.CreatedAt, dbtime.Now()),
|
||||
DisplayName: []string{takeFirst(orig.DisplayName, namesgenerator.GetRandomName(1))},
|
||||
Icon: []string{takeFirst(orig.Icon, namesgenerator.GetRandomName(1))},
|
||||
})
|
||||
require.NoError(t, err, "insert workspace agent log source")
|
||||
return sources[0]
|
||||
}
|
||||
|
||||
func WorkspaceBuild(t testing.TB, db database.Store, orig database.WorkspaceBuild) database.WorkspaceBuild {
|
||||
buildID := takeFirst(orig.ID, uuid.New())
|
||||
var build database.WorkspaceBuild
|
||||
|
Reference in New Issue
Block a user