mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
feat: add template activity_bump property (#11734)
Allows template admins to configure the activity bump duration. Defaults to 1h.
This commit is contained in:
@ -23,6 +23,7 @@ func (r *RootCmd) templateEdit() *clibase.Cmd {
|
||||
description string
|
||||
icon string
|
||||
defaultTTL time.Duration
|
||||
activityBump time.Duration
|
||||
maxTTL time.Duration
|
||||
autostopRequirementDaysOfWeek []string
|
||||
autostopRequirementWeeks int64
|
||||
@ -108,6 +109,10 @@ func (r *RootCmd) templateEdit() *clibase.Cmd {
|
||||
defaultTTL = time.Duration(template.DefaultTTLMillis) * time.Millisecond
|
||||
}
|
||||
|
||||
if !userSetOption(inv, "activity-bump") {
|
||||
activityBump = time.Duration(template.ActivityBumpMillis) * time.Millisecond
|
||||
}
|
||||
|
||||
if !userSetOption(inv, "allow-user-autostop") {
|
||||
allowUserAutostop = template.AllowUserAutostop
|
||||
}
|
||||
@ -168,12 +173,13 @@ func (r *RootCmd) templateEdit() *clibase.Cmd {
|
||||
}
|
||||
|
||||
req := codersdk.UpdateTemplateMeta{
|
||||
Name: name,
|
||||
DisplayName: displayName,
|
||||
Description: description,
|
||||
Icon: icon,
|
||||
DefaultTTLMillis: defaultTTL.Milliseconds(),
|
||||
MaxTTLMillis: maxTTL.Milliseconds(),
|
||||
Name: name,
|
||||
DisplayName: displayName,
|
||||
Description: description,
|
||||
Icon: icon,
|
||||
DefaultTTLMillis: defaultTTL.Milliseconds(),
|
||||
ActivityBumpMillis: activityBump.Milliseconds(),
|
||||
MaxTTLMillis: maxTTL.Milliseconds(),
|
||||
AutostopRequirement: &codersdk.TemplateAutostopRequirement{
|
||||
DaysOfWeek: autostopRequirementDaysOfWeek,
|
||||
Weeks: autostopRequirementWeeks,
|
||||
@ -233,6 +239,11 @@ func (r *RootCmd) templateEdit() *clibase.Cmd {
|
||||
Description: "Edit the template default time before shutdown - workspaces created from this template default to this value. Maps to \"Default autostop\" in the UI.",
|
||||
Value: clibase.DurationOf(&defaultTTL),
|
||||
},
|
||||
{
|
||||
Flag: "activity-bump",
|
||||
Description: "Edit the template activity bump - workspaces created from this template will have their shutdown time bumped by this value when activity is detected. Maps to \"Activity bump\" in the UI.",
|
||||
Value: clibase.DurationOf(&activityBump),
|
||||
},
|
||||
{
|
||||
Flag: "max-ttl",
|
||||
Description: "Edit the template maximum time before shutdown - workspaces created from this template must shutdown within the given duration after starting, regardless of user activity. This is an enterprise-only feature. Maps to \"Max lifetime\" in the UI.",
|
||||
|
Reference in New Issue
Block a user