Skip to content

Commit

Permalink
526 allowed values location (Azure#593)
Browse files Browse the repository at this point in the history
* Fixing Azure#526 - location related issues with AllowedValues

* Adding positive test for Azure#526
  • Loading branch information
StartAutomating committed Feb 15, 2022
1 parent 4889da4 commit 22e9196
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ foreach ($av in $allowedValues) { # Walk thru each thing we find.



$paramName = if ($parent.name) { $parent.name } elseif ($configName) { $configName }

if ($MainTemplateParam.allowedValues) { # If the main template parameter has allowed values
$paramName = if ($parent.name) { $parent.name } elseif ($configName) { $configName }

:CheckNextValue # then we want to check each value in order to see if it's permitted.
foreach ($rv in $reallyAllowedValues) {
foreach ($v in $MainTemplateParam.allowedValues) {
Expand All @@ -96,6 +98,7 @@ foreach ($av in $allowedValues) { # Walk thru each thing we find.
}

if ($MainTemplateParam.defaultValue -and # If the main template has a default value
$MainTemplateParam.defaultValue -replace '\s' -ne '[resourceGroup().location]' -and # and it's not [resourceGroup().location]
$reallyAllowedValues -notcontains $MainTemplateParam.defaultValue) { # and the allowedValues list doesn't contain it.


Expand All @@ -111,7 +114,7 @@ foreach ($av in $allowedValues) { # Walk thru each thing we find.

}
if (-not $foundDefaultValue) {
Write-Error "CreateUIDefinition parameter $($parent.Name) is not allowed in the main template parameter $($theOutput.Name)" -ErrorId Allowed.Value.Default.Mismatch
Write-Error "CreateUIDefinition parameter '$paramName' default value is not allowed in the main template parameter '$($theOutput.Name)'" -ErrorId Allowed.Value.Default.Mismatch
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
"handler": "Microsoft.Azure.CreateUIDef",
"version": "0.1.2-preview",
"parameters": {
"config": {
"isWizard": false,
"basics": {
"description": "sample description",
"location": {
"allowedValues": [
"eastus",
"eastus2"
]
}
}
},
"basics": [
{
"name": "actionSection",
"type": "Microsoft.Common.Section",
"label": "sample label",
"elements": [
{
"name": "createOrUpdate",
"type": "Microsoft.Common.OptionsGroup",
"label": "Select one:",
"constraints": {
"allowedValues": [
{
"label": "Create",
"value": "Create"
},
{
"label": "Update",
"value": "Update"
}
]
}
}
]
}
],
"steps": [
{
"name": "configureStep",
"label": "Configure Step",
"elements": [
{
"name": "nodeSection",
"type": "Microsoft.Common.Section",
"label": " Size of your Node",
"elements": [
{
"name": "nodeSize",
"type": "Microsoft.Compute.SizeSelector",
"label": "Node size:",
"recommendedSizes": [
"Standard_F16s_v2"
],
"constraints": {
"allowedSizes": [
"Standard_F8s_v2",
"Standard_F16s_v2"
]
},
"osPlatform": "Linux",
"count": 1
}
]
}
]
},
{
"name": "updateStep",
"label": "Update Configuration",
"elements": [
{
"name": "updateSection",
"type": "Microsoft.Common.Section",
"label": "Update",
"elements": [
{
"name": "userAssignedIdentitiesApi",
"type": "Microsoft.Solutions.ArmApiControl",
"request": {
"method": "GET",
"path": "[concat(subscription().id,'/resourceGroups/',resourceGroup().name, '/providers/Microsoft.ManagedIdentity/userAssignedIdentities?api-version=2018-11-30')]"
}
},
{
"name": "userAssignedIdentitiesDropDown",
"type": "Microsoft.Common.DropDown",
"label": "Select deployment user identity:",
"constraints": {
"allowedValues": "[map(steps('updateStep').updateSection.userAssignedIdentitiesApi.value, (item) => parse(concat('{\"label\":\"', item.name, '\",\"value\":\"', item.id, '\"}')))]"
}
}
]
}
]
}
],
"outputs": {
"location": "[location()]",
"createOrUpdate": "[basics('actionSection').createOrUpdate]",
"nodeSize": "[steps('configureStep').nodeSection.nodeSize]",
"updateIdentityId": "[steps('updateStep').updateSection.userAssignedIdentitiesDropDown]"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"nodeSize": {
"type": "string",
"defaultValue": "Standard_F16s_v2",
"allowedValues": [
"Standard_F16s_v2"
],
"metadata": {
"description": "The size of the Virtual Machine."
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "The location of the Managed Cluster resource."
}
},
"createOrUpdate": {
"type": "string",
"defaultValue": "Create",
"allowedValues": [
"Create",
"Update"
]
},
"updateIdentityId": {
"type": "string",
"defaultValue": "N/A"
}
},
"resources": [
]
}

0 comments on commit 22e9196

Please sign in to comment.