Skip to content

(GH-538) Define date version#1427

Merged
SteveL-MSFT merged 1 commit intoPowerShell:mainfrom
michaeltlombardi:gh-538/main/date-version
Mar 12, 2026
Merged

(GH-538) Define date version#1427
SteveL-MSFT merged 1 commit intoPowerShell:mainfrom
michaeltlombardi:gh-538/main/date-version

Conversation

@michaeltlombardi
Copy link
Collaborator

PR Summary

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.

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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 DateVersion type 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::InvalidDateVersion variant.

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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@michaeltlombardi michaeltlombardi marked this pull request as ready for review March 11, 2026 21:53
@SteveL-MSFT SteveL-MSFT added this pull request to the merge queue Mar 12, 2026
Merged via the queue into PowerShell:main with commit 017058b Mar 12, 2026
40 of 41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants