mirror of
https://github.com/coder/coder.git
synced 2025-07-08 11:39:50 +00:00
feat: add controls to template for determining startup days (#10226)
* feat: template controls which days can autostart * Add unit test to test blocking autostart with DaysOfWeek
This commit is contained in:
@ -31,11 +31,13 @@ type Template struct {
|
||||
DefaultTTLMillis int64 `json:"default_ttl_ms"`
|
||||
// TODO(@dean): remove max_ttl once autostop_requirement is matured
|
||||
MaxTTLMillis int64 `json:"max_ttl_ms"`
|
||||
// AutostopRequirement is an enterprise feature. Its value is only used if
|
||||
// your license is entitled to use the advanced template scheduling feature.
|
||||
AutostopRequirement TemplateAutostopRequirement `json:"autostop_requirement"`
|
||||
CreatedByID uuid.UUID `json:"created_by_id" format:"uuid"`
|
||||
CreatedByName string `json:"created_by_name"`
|
||||
// AutostopRequirement and AutostartRequirement are enterprise features. Its
|
||||
// value is only used if your license is entitled to use the advanced template
|
||||
// scheduling feature.
|
||||
AutostopRequirement TemplateAutostopRequirement `json:"autostop_requirement"`
|
||||
AutostartRequirement TemplateAutostartRequirement `json:"autostart_requirement"`
|
||||
CreatedByID uuid.UUID `json:"created_by_id" format:"uuid"`
|
||||
CreatedByName string `json:"created_by_name"`
|
||||
|
||||
// AllowUserAutostart and AllowUserAutostop are enterprise-only. Their
|
||||
// values are only used if your license is entitled to use the advanced
|
||||
@ -107,6 +109,12 @@ func BitmapToWeekdays(bitmap uint8) []string {
|
||||
return days
|
||||
}
|
||||
|
||||
type TemplateAutostartRequirement struct {
|
||||
// DaysOfWeek is a list of days of the week in which autostart is allowed
|
||||
// to happen. If no days are specified, autostart is not allowed.
|
||||
DaysOfWeek []string `json:"days_of_week" enums:"monday,tuesday,wednesday,thursday,friday,saturday,sunday"`
|
||||
}
|
||||
|
||||
type TemplateAutostopRequirement struct {
|
||||
// DaysOfWeek is a list of days of the week on which restarts are required.
|
||||
// Restarts happen within the user's quiet hours (in their configured
|
||||
@ -193,16 +201,17 @@ type UpdateTemplateMeta struct {
|
||||
DefaultTTLMillis int64 `json:"default_ttl_ms,omitempty"`
|
||||
// TODO(@dean): remove max_ttl once autostop_requirement is matured
|
||||
MaxTTLMillis int64 `json:"max_ttl_ms,omitempty"`
|
||||
// AutostopRequirement can only be set if your license includes the advanced
|
||||
// template scheduling feature. If you attempt to set this value while
|
||||
// unlicensed, it will be ignored.
|
||||
AutostopRequirement *TemplateAutostopRequirement `json:"autostop_requirement,omitempty"`
|
||||
AllowUserAutostart bool `json:"allow_user_autostart,omitempty"`
|
||||
AllowUserAutostop bool `json:"allow_user_autostop,omitempty"`
|
||||
AllowUserCancelWorkspaceJobs bool `json:"allow_user_cancel_workspace_jobs,omitempty"`
|
||||
FailureTTLMillis int64 `json:"failure_ttl_ms,omitempty"`
|
||||
TimeTilDormantMillis int64 `json:"time_til_dormant_ms,omitempty"`
|
||||
TimeTilDormantAutoDeleteMillis int64 `json:"time_til_dormant_autodelete_ms,omitempty"`
|
||||
// AutostopRequirement and AutostartRequirement can only be set if your license
|
||||
// includes the advanced template scheduling feature. If you attempt to set this
|
||||
// value while unlicensed, it will be ignored.
|
||||
AutostopRequirement *TemplateAutostopRequirement `json:"autostop_requirement,omitempty"`
|
||||
AutostartRequirement *TemplateAutostartRequirement `json:"autostart_requirement,omitempty"`
|
||||
AllowUserAutostart bool `json:"allow_user_autostart,omitempty"`
|
||||
AllowUserAutostop bool `json:"allow_user_autostop,omitempty"`
|
||||
AllowUserCancelWorkspaceJobs bool `json:"allow_user_cancel_workspace_jobs,omitempty"`
|
||||
FailureTTLMillis int64 `json:"failure_ttl_ms,omitempty"`
|
||||
TimeTilDormantMillis int64 `json:"time_til_dormant_ms,omitempty"`
|
||||
TimeTilDormantAutoDeleteMillis int64 `json:"time_til_dormant_autodelete_ms,omitempty"`
|
||||
// UpdateWorkspaceLastUsedAt updates the last_used_at field of workspaces
|
||||
// spawned from the template. This is useful for preventing workspaces being
|
||||
// immediately locked when updating the inactivity_ttl field to a new, shorter
|
||||
|
Reference in New Issue
Block a user