(GH-538) Define date version#1427
Conversation
There was a problem hiding this comment.
Pull request overview
Introduces a new DateVersion type in dsc-lib to represent ARM-style apiVersion values as ISO8601 dates with an optional prerelease suffix, replacing the prior “arbitrary string” approach for date-based versions.
Changes:
- Added
DateVersiontype with parsing/validation, serde (string) conversion, ordering/equality, and JSON Schema support. - Added integration tests covering parsing, traits, serde behavior, ordering, and schema validation.
- Added new localized schema/validation strings and a new
DscError::InvalidDateVersionvariant.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/dsc-lib/src/types/mod.rs | Exposes the new DateVersion type from the types module. |
| lib/dsc-lib/src/types/date_version.rs | Implements DateVersion parsing/validation, serde, schema, and comparison behavior. |
| lib/dsc-lib/src/dscerror.rs | Adds InvalidDateVersion error variant used by DateVersion. |
| lib/dsc-lib/tests/integration/types/mod.rs | Registers the new date_version integration test module. |
| lib/dsc-lib/tests/integration/types/date_version.rs | Adds integration tests for DateVersion behavior and schema generation/validation. |
| lib/dsc-lib/locales/schemas.definitions.yaml | Adds localized schema documentation for the dateVersion definition. |
| lib/dsc-lib/locales/en-us.toml | Adds localized error strings for date version parsing/validation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
8716fb1 to
834ea5d
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
834ea5d to
44b051e
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Prior to this change, DSC allowed resources to define their version as either a semantic version or an arbitrary string. This change defines the `DateVersion` type to replace the arbitrary string version. It adheres to the practices for `apiVersion` definitions in ARM templates by: - Serializing to/from a string - Defining the version as an ISO8601 date with an optional prerelease segment. While the _validating schema_ for `apiVersion` only checks that the value is a string, in practice every resource type defines `apiVersion` as an ISO8601 date. Some of them define a fourth segment to indicate a prerelease version, like `2026-02-03-preview`. The prerelease segment for every currently available resource type are defined with only upper and lowercase ASCII alphabetics. This implementation: - Parses a string containing an ISO8601 date and optional prerelease segment. - Uses a regular expression for initial validation and extracting the date components. - Forbids leading and trailing spaces for the string. - Forbids the year for the date from starting with zero. - Forbids invalid dates, like a leap day on a non-leap year. - Implements the `Datelike` trait from the `chrono` crate, simplifying the extraction of date components like `version.month()`. - Implements ordering and equivalency traits. This change doesn't update the implementation for `ResourceVersion` to replace the arbitrary string version. This will need to be addressed in a future change.
44b051e to
48ac12a
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
PR Summary
This change defines the
DateVersiontype to replace the arbitrary string version. It adheres to the practices forapiVersiondefinitions in ARM templates by:While the validating schema for
apiVersiononly checks that the value is a string, in practice every resource type definesapiVersionas an ISO8601 date. Some of them define a fourth segment to indicate a prerelease version, like2026-02-03-preview. The prerelease segment for every currently available resource type are defined with only upper and lowercase ASCII alphabetics.This implementation:
Dateliketrait from thechronocrate, simplifying the extraction of date components likeversion.month().This change doesn't update the implementation for
ResourceVersionto replace the arbitrary string version. This will need to be addressed in a future change.PR Context
Prior to this change, DSC allowed resources to define their version as either a semantic version or an arbitrary string. The WG decided to more formally define the compatibility version for a resource to suit the compatibility usage.