Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
address PR comments
  • Loading branch information
johnstcn committed Apr 18, 2022
commit be426af6abda55c4ba0b3571cc547ae39e65406e
6 changes: 3 additions & 3 deletions cli/workspaceautostart.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import (

const autostartDescriptionLong = `To have your workspace build automatically at a regular time you can enable autostart.
When enabling autostart, provide the minute, hour, and day(s) of week.
The default schedule is at 0900 in your local timezone (TZ env, UTC by default).
The default schedule is at 09:00 in your local timezone (TZ env, UTC by default).
`

func workspaceAutostart() *cobra.Command {
autostartCmd := &cobra.Command{
Use: "autostart enable <workspace>",
Short: "schedule a workspace to automatically start at a regular time",
Long: autostartDescriptionLong,
Example: "coder workspaces autostart enable my-workspace --minute 30 --hour 9 --dow 1-5 --tz Europe/Dublin",
Example: "coder workspaces autostart enable my-workspace --minute 30 --hour 9 --days 1-5 --tz Europe/Dublin",
Hidden: true, // TODO(cian): un-hide when autostart scheduling implemented
}

Expand Down Expand Up @@ -73,7 +73,7 @@ func workspaceAutostartEnable() *cobra.Command {

cmd.Flags().StringVar(&autostartMinute, "minute", "0", "autostart minute")
cmd.Flags().StringVar(&autostartHour, "hour", "9", "autostart hour")
cmd.Flags().StringVar(&autostartDayOfWeek, "dow", "1-5", "autostart hour")
cmd.Flags().StringVar(&autostartDayOfWeek, "days", "1-5", "autostart day(s) of week")
tzEnv := os.Getenv("TZ")
if tzEnv == "" {
tzEnv = "UTC"
Expand Down
2 changes: 1 addition & 1 deletion cli/workspaceautostart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestWorkspaceAutostart(t *testing.T) {
project = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
workspace = coderdtest.CreateWorkspace(t, client, codersdk.Me, project.ID)
tz = "Europe/Dublin"
cmdArgs = []string{"workspaces", "autostart", "enable", workspace.Name, "--minute", "30", "--hour", "9", "--dow", "1-5", "--tz", tz}
cmdArgs = []string{"workspaces", "autostart", "enable", workspace.Name, "--minute", "30", "--hour", "9", "--days", "1-5", "--tz", tz}
sched = "CRON_TZ=Europe/Dublin 30 9 * * 1-5"
stdoutBuf = &bytes.Buffer{}
)
Expand Down
6 changes: 3 additions & 3 deletions cli/workspaceautostop.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import (

const autostopDescriptionLong = `To have your workspace stop automatically at a regular time you can enable autostop.
When enabling autostop, provide the minute, hour, and day(s) of week.
The default autostop schedule is at 1800 in your local timezone (TZ env, UTC by default).
The default autostop schedule is at 18:00 in your local timezone (TZ env, UTC by default).
`

func workspaceAutostop() *cobra.Command {
autostopCmd := &cobra.Command{
Use: "autostop enable <workspace>",
Short: "schedule a workspace to automatically stop at a regular time",
Long: autostopDescriptionLong,
Example: "coder workspaces autostop enable my-workspace -minute 0 -hour 18 -dow 1-5 -tz Europe/Dublin",
Example: "coder workspaces autostop enable my-workspace --minute 0 --hour 18 --days 1-5 -tz Europe/Dublin",
Hidden: true, // TODO(cian): un-hide when autostop scheduling implemented
}

Expand Down Expand Up @@ -73,7 +73,7 @@ func workspaceAutostopEnable() *cobra.Command {

cmd.Flags().StringVar(&autostopMinute, "minute", "0", "autostop minute")
cmd.Flags().StringVar(&autostopHour, "hour", "18", "autostop hour")
cmd.Flags().StringVar(&autostopDayOfWeek, "dow", "1-5", "autostop hour")
cmd.Flags().StringVar(&autostopDayOfWeek, "days", "1-5", "autostop day(s) of week")
tzEnv := os.Getenv("TZ")
if tzEnv == "" {
tzEnv = "UTC"
Expand Down
2 changes: 1 addition & 1 deletion cli/workspaceautostop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestWorkspaceAutostop(t *testing.T) {
_ = coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
project = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
workspace = coderdtest.CreateWorkspace(t, client, codersdk.Me, project.ID)
cmdArgs = []string{"workspaces", "autostop", "enable", workspace.Name, "--minute", "30", "--hour", "17", "--dow", "1-5", "--tz", "Europe/Dublin"}
cmdArgs = []string{"workspaces", "autostop", "enable", workspace.Name, "--minute", "30", "--hour", "17", "--days", "1-5", "--tz", "Europe/Dublin"}
sched = "CRON_TZ=Europe/Dublin 30 17 * * 1-5"
stdoutBuf = &bytes.Buffer{}
)
Expand Down
4 changes: 2 additions & 2 deletions site/src/test_helpers/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const MockWorkspaceAutostartDisabled: WorkspaceAutostartRequest = {
export const MockWorkspaceAutostartEnabled: WorkspaceAutostartRequest = {
// Runs at 9:30am Monday through Friday using Canada/Eastern
// (America/Toronto) time
schedule: "CRON_TZ=Canada/Eastern 30 9 1-5",
schedule: "CRON_TZ=Canada/Eastern 30 9 * * 1-5",
}

export const MockWorkspaceAutostopDisabled: WorkspaceAutostartRequest = {
Expand All @@ -77,7 +77,7 @@ export const MockWorkspaceAutostopDisabled: WorkspaceAutostartRequest = {

export const MockWorkspaceAutostopEnabled: WorkspaceAutostartRequest = {
// Runs at 9:30pm Monday through Friday using America/Toronto
schedule: "CRON_TZ=America/Toronto 30 21 1-5",
schedule: "CRON_TZ=America/Toronto 30 21 * * 1-5",
}

export const MockWorkspace: Workspace = {
Expand Down