-
Notifications
You must be signed in to change notification settings - Fork 52
Enable user functions in configurations #1096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enables user-defined functions in DSC configurations following ARM template limitations. The implementation adds support for custom functions defined in a functions
section of the configuration with namespace-based scoping and restrictions on what built-in functions can be called from within user functions.
Key changes include:
- Added user function definitions to configuration schema with parameters and output specifications
- Implemented user function invocation with parameter validation and type checking
- Added restrictions preventing user functions from calling certain built-in functions like
reference()
,variables()
, andutcNow()
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
tree-sitter-dscexpression/grammar.js | Updated function name regex to support dot notation for namespaced user functions |
tree-sitter-dscexpression/test/corpus/valid_expressions.txt | Added test case for user function syntax |
tree-sitter-dscexpression/test/corpus/invalid_expressions.txt | Updated test expectations for error cases |
dsc_lib/src/configure/config_doc.rs | Added data structures for user function definitions |
dsc_lib/src/configure/context.rs | Added ProcessMode enum and user_functions field to Context |
dsc_lib/src/configure/mod.rs | Added user function initialization logic |
dsc_lib/src/functions/user_function.rs | Implemented core user function invocation and validation logic |
dsc_lib/src/functions/mod.rs | Added user function dispatch and enhanced error messages |
dsc_lib/src/functions/variables.rs | Added restriction preventing use in user functions |
dsc_lib/src/functions/reference.rs | Added restriction preventing use in user functions |
dsc_lib/src/functions/utc_now.rs | Updated to use ProcessMode instead of boolean flag |
dsc_lib/src/parser/mod.rs | Updated to use ProcessMode enum |
dsc_lib/src/dscresources/dscresource.rs | Updated to use ProcessMode enum |
dsc_lib/locales/en-us.toml | Added localized error messages for user functions |
dsc/tests/dsc_user_functions.tests.ps1 | Added comprehensive test suite for user function functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
51cf6c0
to
6bfe059
Compare
dc7d2f9
to
44270aa
Compare
PR Summary
Enable user functions in a configurations following the limitations defined by ARM.
User functions, just like built-in functions, are case sensitive.
Expression grammar needed slight modification to allow for function names to contain a single period.
PR Context
Fix #1018