mirror of
https://github.com/coder/coder.git
synced 2025-07-21 01:28:49 +00:00
fix: cli: prettify schedule when printing output (#1440)
* Adds methods to schedule.Schedule to show the raw cron string and timezone * Uses these methods to clean up output of auto(start|stop) show or ls * Defaults CRON_TZ=UTC if not provided
This commit is contained in:
13
cli/list.go
13
cli/list.go
@ -10,6 +10,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/coder/coder/cli/cliui"
|
||||
"github.com/coder/coder/coderd/autobuild/schedule"
|
||||
"github.com/coder/coder/coderd/database"
|
||||
"github.com/coder/coder/codersdk"
|
||||
)
|
||||
@ -108,14 +109,18 @@ func list() *cobra.Command {
|
||||
durationDisplay = durationDisplay[:len(durationDisplay)-2]
|
||||
}
|
||||
|
||||
autostartDisplay := "not enabled"
|
||||
autostartDisplay := "-"
|
||||
if workspace.AutostartSchedule != "" {
|
||||
autostartDisplay = workspace.AutostartSchedule
|
||||
if sched, err := schedule.Weekly(workspace.AutostartSchedule); err == nil {
|
||||
autostartDisplay = sched.Cron()
|
||||
}
|
||||
}
|
||||
|
||||
autostopDisplay := "not enabled"
|
||||
autostopDisplay := "-"
|
||||
if workspace.AutostopSchedule != "" {
|
||||
autostopDisplay = workspace.AutostopSchedule
|
||||
if sched, err := schedule.Weekly(workspace.AutostopSchedule); err == nil {
|
||||
autostopDisplay = sched.Cron()
|
||||
}
|
||||
}
|
||||
|
||||
user := usersByID[workspace.OwnerID]
|
||||
|
Reference in New Issue
Block a user