MCPcopy Index your code
hub / github.com/coder/coder / validateDailySpec

Function validateDailySpec

coderd/schedule/cron/cron.go:294–306  ·  view source on GitHub ↗

validateDailySpec ensures that the day-of-month, month and day-of-week options of spec are all set to *

(spec string)

Source from the content-addressed store, hash-verified

292// validateDailySpec ensures that the day-of-month, month and day-of-week
293// options of spec are all set to *
294func validateDailySpec(spec string) error {
295 parts := strings.Fields(spec)
296 if len(parts) < 5 {
297 return xerrors.Errorf("expected schedule to consist of 5 fields with an optional CRON_TZ=<timezone> prefix")
298 }
299 if len(parts) == 6 {
300 parts = parts[1:]
301 }
302 if parts[2] != "*" || parts[3] != "*" || parts[4] != "*" {
303 return xerrors.Errorf("expected day-of-month, month and day-of-week to be *")
304 }
305 return nil
306}
307
308// validateTimeRangeSpec ensures that the minutes field is set to *
309func validateTimeRangeSpec(spec string) error {

Callers 1

DailyFunction · 0.85

Calls 2

FieldsMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected