Skip to content

Commit

Permalink
workaround for Azure#629 (Azure#631)
Browse files Browse the repository at this point in the history
* workaround for 629

* fix unit tests

* fix unit tests
  • Loading branch information
bmoore-msft committed Apr 6, 2022
1 parent 05ed3cf commit 5d84bb9
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $IsInnerTemplate,
[Collections.IDictionary]
$AllowedFunctionInOutput = $(@{
int = 'int', 'min', 'max', 'div', 'add', 'mod', 'mul', 'sub', 'copyIndex','length', 'coalesce'
bool = 'equals', 'less', 'lessOrEquals', 'greater', 'greaterOrEquals', 'and', 'or','not', 'true', 'false', 'contains','empty','coalesce','if'
bool = 'bool', 'equals', 'less', 'lessOrEquals', 'greater', 'greaterOrEquals', 'and', 'or','not', 'true', 'false', 'contains','empty','coalesce','if'
})
)

Expand Down Expand Up @@ -68,6 +68,22 @@ foreach ($output in $parameterInfo.outputs.psobject.properties) { # Then walk th
Write-Error "output $outputName does not exist in template.parameters" -ErrorId CreateUIDefinition.Output.Missing.From.MainTemplate -TargetObject $parameterInfo.outputs
}

# check that the type of the output matches the type declared in the template, note that the output type may be set on the control itself through the same expression
<#
TODO:
Removing the test for now... there are some controls in CUID that allow setting the value explicitly
For these controls we need to check that value property for the allowed functions or type
Some of these controls are arrays of values, so we would have to look at each array element for the allowedFunctions
Cases to consider:
- Checkbox control already returns a bool
- DropDown control - array of objects that contain a value property
- OptionsGroup - array of objects that contain a value property
- slider - returns an int
Note that these controls can be complex and nested and if the output value does not comply, only then do we need to check the control value for the output
With coalescing, this can be tricky.
$outputParameterType = $TemplateObject.parameters.$outputName.type
if ($outputParameterType -and $outputParameterType -ne 'string') {
$firstOutputFunction = $output.Value | ?<ARM_Template_Function> -Extract | Select-Object -ExpandProperty FunctionName
Expand All @@ -79,4 +95,5 @@ foreach ($output in $parameterInfo.outputs.psobject.properties) { # Then walk th
}
}
}
#>
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
]
}
],
// TODO: move this test back to FAIL folder when #629 is properly fixed
"outputs": {
"location": "[location()]",
"testBoolean": "[int('1')]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
}
],
"outputs": {
// TODO: move this test back to FAIL folder when #629 is properly fixed
"location": "[location()]",
"swarmRootDiskSize": "[steps('SwarmConfig').vmSettings.rootDiskSize]"
}
Expand Down

0 comments on commit 5d84bb9

Please sign in to comment.