feat(cli): allow showing schedules for multiple workspaces (#10596)

* coder list: adds information about next start / stop to available columns (not default)
* coder schedule: show now essentially coder list with a different set of columns
* Updates cli schedule unit tests to use new dbfake

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
This commit is contained in:
Cian Johnston
2023-11-10 13:51:49 +00:00
committed by GitHub
co-authored by Mathias Fredriksson
parent 177affbe4b
commit a4f1319108
13 changed files with 544 additions and 466 deletions
+14 -1
View File
@@ -115,7 +115,7 @@ type Schedule struct {
cronStr string
}
// String serializes the schedule to its original human-friendly format.
// String serializes the schedule to its original format.
// The leading CRON_TZ is maintained.
func (s Schedule) String() string {
var sb strings.Builder
@@ -126,6 +126,19 @@ func (s Schedule) String() string {
return sb.String()
}
// Humanize returns a slightly more human-friendly representation of the
// schedule.
func (s Schedule) Humanize() string {
var sb strings.Builder
_, _ = sb.WriteString(s.Time())
_, _ = sb.WriteString(" ")
_, _ = sb.WriteString(s.DaysOfWeek())
_, _ = sb.WriteString(" (")
_, _ = sb.WriteString(s.Location().String())
_, _ = sb.WriteString(")")
return sb.String()
}
// Location returns the IANA location for the schedule.
func (s Schedule) Location() *time.Location {
return s.sched.Location