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

Function validateWeeklySpec

coderd/schedule/cron/cron.go:278–290  ·  view source on GitHub ↗

validateWeeklySpec ensures that the day-of-month and month options of spec are both set to *

(spec string)

Source from the content-addressed store, hash-verified

276// validateWeeklySpec ensures that the day-of-month and month options of
277// spec are both set to *
278func validateWeeklySpec(spec string) error {
279 parts := strings.Fields(spec)
280 if len(parts) < 5 {
281 return xerrors.Errorf("expected schedule to consist of 5 fields with an optional CRON_TZ=<timezone> prefix")
282 }
283 if len(parts) == 6 {
284 parts = parts[1:]
285 }
286 if parts[2] != "*" || parts[3] != "*" {
287 return xerrors.Errorf("expected day-of-month and month to be *")
288 }
289 return nil
290}
291
292// validateDailySpec ensures that the day-of-month, month and day-of-week
293// options of spec are all set to *

Callers 1

WeeklyFunction · 0.85

Calls 2

FieldsMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected