serverlessworkflow / sdk-go

Go SDK for Serverless Workflow
http://serverlessworkflow.io
Apache License 2.0
90 stars 35 forks source link

Fixed Cron.ValidUntil using incorrect ISO8601 parsing format #187

Closed venera-program closed 1 year ago

venera-program commented 1 year ago

What this PR does / why we need it: The parsing method currently used for validating Cron.ValidUntil tries to convert the given value to ISO8601 Duration when it should be parsing for Datetime.

You can see this in the 0.8 spec's example definition found here: https://github.com/serverlessworkflow/specification/blob/0.8.x/specification.md#cron-definition

validUntil | Specific date and time (ISO 8601 format) when the cron expression is no longer valid

Special notes for reviewers: If there is a preference for a different ISO8601 timestamp parser library over github.com/relvacode/iso8601 I am welcome to any suggestions.

spolti commented 1 year ago

Hi @venera-program Thanks for submitting this PR. Isn't the time.Parse() enough? It can handle RFC-3339 / ISO-8601 date-time as well.

venera-program commented 1 year ago

@spolti How would we determine the correct layout to use in time.Parse(layout, value string)? Serverless spec does not define a specific format other than "ISO 8601 format" for this field. Additionally, there is no field for specifying a layout for ValidUntil; therefore we should probably aim to support as many layout variations as we can allow. Using time.Parse does not sufficiently fill that role.