From 087ccbfcce658328149dba03a4e68dd12f282bda Mon Sep 17 00:00:00 2001 From: Dominik Rastawicki Date: Mon, 18 Apr 2022 15:18:36 +0800 Subject: [PATCH] Enforce 0 second time restriction on schedules --- pagerduty/util.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pagerduty/util.go b/pagerduty/util.go index e8cb33ea9..ea256a931 100644 --- a/pagerduty/util.go +++ b/pagerduty/util.go @@ -22,9 +22,13 @@ func timeToUTC(v string) (time.Time, error) { // validateRFC3339 validates that a date string has the correct RFC3339 layout func validateRFC3339(v interface{}, k string) (we []string, errors []error) { value := v.(string) - if _, err := time.Parse(time.RFC3339, value); err != nil { + t, err := time.Parse(time.RFC3339, value) + if err != nil { errors = append(errors, fmt.Errorf("%s is not a valid format for argument: %s. Expected format: %s (RFC3339)", value, k, time.RFC3339)) } + if t.Second() > 0 { + errors = append(errors, fmt.Errorf("please set the time %s to a full minute, e.g. 11:23:00, not 11:23:05", value)) + } return }