Skip to content
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

Merged
merged 7 commits into from
Nov 20, 2023

Conversation

psah434
Copy link
Collaborator

@psah434 psah434 commented Oct 25, 2023

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.

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"})
Copy link
Collaborator

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

Copy link
Collaborator Author

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
Copy link
Collaborator

Choose a reason for hiding this comment

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

i thinkyou need .*[ right ?

Copy link
Collaborator Author

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

Copy link
Collaborator

@raosuhas raosuhas left a comment

Choose a reason for hiding this comment

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

:shipit:

@psah434 psah434 merged commit c52c8dc into Azure:master Nov 20, 2023
2 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