-
Notifications
You must be signed in to change notification settings - Fork 193
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
Addressing fixes for GitHub issues 738, 753 and 745 #754
Conversation
arm-ttk/testcases/deploymentTemplate/Parameter-Types-Should-Be-Consistent.test.ps1
Outdated
Show resolved
Hide resolved
arm-ttk/testcases/deploymentTemplate/Parameter-Types-Should-Be-Consistent.test.ps1
Outdated
Show resolved
Hide resolved
Write-Error -ErrorId Inconsistent.Parameter -Message "Type Mismatch: Parameter '$parameterName' in nested template '$($inner.ParentObject[0].name)' is defined as $innerTemplateParameterType, but the parent template defines it as $($parent.parameters.$mappedParameterName.type))." -TargetObject ([PSCustomObject]@{ | ||
JSONPath = $inner.JSONPath + ".parameters.$parameterName" | ||
}) | ||
JSONPath = $inner.JSONPath + ".parameters.$parameterName"}) |
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.
undo this part of the change
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.
Fixed
) { | ||
$innerTemplateParamValue = $innerTemplateParam.Value | ||
$regexParam = ".*parameters(?<mappedParameterName>\(.*\))(\[.*?\]|\.|\,)(.*)\]" # https://regex101.com/r/V0dzVv/1 and https://regex101.com/r/ao6tsK/1 https://github.com/Azure/arm-ttk/issues/635 |
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.
i thinkyou need .*[ right ?
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.
it is [.*, will add it
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.
Before this fix if an inner template parameter referenced a parent template parameter, if the value of the inner template parameter was not in the form [parameters('parenttemplateparam').....] or [parameters('parenttemplateparam')] then an error would be thrown. This PR fixes the regex where the error will not be thrown to include values like *parameter('parenttemplateparam')... or *parameter('parenttemplateparam'), or *parameter('parenttemplateparam')]
Also if the VALUE of an innertemplateparam is an object, then the correct value was not retrieved previously. This is also fixed.
Addressing issues:
#745
(Removed the condition to have '[' before parameters and a comma can be accepted besides '.' and ']')
Test file unit-tests/Parameter-Types-Should-Be-Consistent/Pass/bicepTemplate.json is related
#753
Test file unit-tests/Parameter-Types-Should-Be-Consistent/Pass/innerParamArrayBicepTemplate.json is a test for this issue
The code change where the inner template parameter value.value is retrieved and if the type is not a string then the error is not thrown.
#738
Test file unit-tests/Parameter-Types-Should-Be-Consistent/Pass/twoModuleBicepTemplate.json is a test for this issue
The regex fix to remove the requirement of the regex to always have its value to begin with '[parameters' is lifted.