-
Notifications
You must be signed in to change notification settings - Fork 580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
autostart/autostop: move to traditional 5-valued cron string for compatibility #1049
Conversation
…ules, automatically set timezone
Codecov Report
@@ Coverage Diff @@
## main #1049 +/- ##
==========================================
+ Coverage 67.31% 67.45% +0.13%
==========================================
Files 259 259
Lines 15061 15100 +39
Branches 152 152
==========================================
+ Hits 10139 10185 +46
+ Misses 3899 3896 -3
+ Partials 1023 1019 -4
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nits. LGTM
RunE: func(cmd *cobra.Command, args []string) error { | ||
client, err := createClient(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
workspace, err := client.WorkspaceByName(cmd.Context(), codersdk.Me, args[0]) | ||
spec := fmt.Sprintf("CRON_TZ=%s %s %s * * %s", autostartTimezone, autostartMinute, autostartHour, autostartDayOfWeek) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: nice!
tzEnv := os.Getenv("TZ") | ||
if tzEnv == "" { | ||
tzEnv = "UTC" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: nice 😎
cli/workspaceautostop.go
Outdated
|
||
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cmd.Flags().StringVar(&autostopDayOfWeek, "dow", "1-5", "autostop hour") | |
cmd.Flags().StringVar(&autostopDayOfWeek, "dow", "1-5", "autostop day(s) of week") |
at: time.Time{}, | ||
expectedNext: time.Time{}, | ||
expectedError: "validate weekly schedule: expected month and dom to be *", | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: Great tests
@johnstcn we're seeing a parse failure in our Storybook. I think we need to update these here to have coder/site/src/test_helpers/entities.ts Lines 64 to 81 in f2904f6
|
ack |
This PR modfies the original 3-valued cron strings used in package
schedule
to be traditional 5-valued cron strings.schedule.Weekly
will validate that themonth
anddom
fields are equal to*
TZ
env var, defaulting to UTC--minute
,--hour
,--dow
, and--tz
arguments. Default schedules are provided that should suffice for most users.Fixes #993