MCPcopy Index your code
hub / github.com/coder/coder / workspaceTTL

Function workspaceTTL

coderd/schedule/autostop.go:258–272  ·  view source on GitHub ↗

workspaceTTL returns the TTL to use for a workspace. If the template forbids custom workspace TTLs, then we always use the template's configured TTL (or 0 if the template has no TTL configured).

(workspace database.WorkspaceTable, templateSchedule TemplateScheduleOptions)

Source from the content-addressed store, hash-verified

256// If the template forbids custom workspace TTLs, then we always use the
257// template's configured TTL (or 0 if the template has no TTL configured).
258func workspaceTTL(workspace database.WorkspaceTable, templateSchedule TemplateScheduleOptions) time.Duration {
259 // If the template forbids custom workspace TTLs, then we always use the
260 // template's configured TTL (or 0 if the template has no TTL configured).
261 if !templateSchedule.UserAutostopEnabled {
262 // This is intentionally a nested if statement because of the else if.
263 if templateSchedule.DefaultTTL > 0 {
264 return templateSchedule.DefaultTTL
265 }
266 return 0
267 }
268 if workspace.Ttl.Valid {
269 return time.Duration(workspace.Ttl.Int64)
270 }
271 return 0
272}
273
274// truncateMidnight truncates a time to midnight in the time object's timezone.
275// t.Truncate(24 * time.Hour) truncates based on the internal time and doesn't

Callers 1

CalculateAutostopFunction · 0.85

Calls 1

DurationMethod · 0.80

Tested by

no test coverage detected