Add endsWith, startsWith, utcNow, and uniqueString functions#1032
Merged
SteveL-MSFT merged 7 commits intoPowerShell:mainfrom Aug 7, 2025
Merged
Add endsWith, startsWith, utcNow, and uniqueString functions#1032SteveL-MSFT merged 7 commits intoPowerShell:mainfrom
endsWith, startsWith, utcNow, and uniqueString functions#1032SteveL-MSFT merged 7 commits intoPowerShell:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds four new string and date functions to the DSC library: endsWith, startsWith, utcNow, and uniqueString. These functions enhance the DSC template expression capabilities with string manipulation and utility operations.
- Implements string prefix/suffix checking with
startsWithandendsWithfunctions - Adds
utcNowfunction for date formatting with .NET format string conversion support - Provides
uniqueStringfunction for generating deterministic hashes from concatenated inputs - Refactors function registration from individual insertions to a vector-based approach for better maintainability
Reviewed Changes
Copilot reviewed 10 out of 13 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| dsc_lib/src/functions/ends_with.rs | New function to check if a string ends with a specified suffix |
| dsc_lib/src/functions/starts_with.rs | New function to check if a string starts with a specified prefix |
| dsc_lib/src/functions/utc_now.rs | New function to get current UTC time with optional .NET format string support |
| dsc_lib/src/functions/unique_string.rs | New function to generate deterministic unique strings from input arguments |
| dsc_lib/src/functions/mod.rs | Refactored function registration and added new function imports |
| dsc_lib/src/configure/context.rs | Added parameter default processing flag to context |
| dsc_lib/src/configure/mod.rs | Updated parameter default processing to use context flag |
| dsc_lib/locales/en-us.toml | Added localization strings for new functions |
| dsc_lib/Cargo.toml | Added dependencies for new functions (base32, murmurhash64) |
| dsc/tests/dsc_functions.tests.ps1 | Added comprehensive tests for new functions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
Add
endsWith(),startsWith(),utcNow(), anduniqueString()functions. Note thatutcNow()supports a subset of the .NET datetime formatting strings.Also refactored how functions get registered with DSC so that it's from a vector and takes the name from the metadata so no risk of them being out of sync.
PR Context
Part of #976