-
Notifications
You must be signed in to change notification settings - Fork 762
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decompile reference() functions with resource name references (#2381)
* Decompile reference() functions with resource name references * Fix decompiler to use LF for newlines * Fix test for LF
- Loading branch information
1 parent
30dd5af
commit 0d8b6fa
Showing
7 changed files
with
306 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/Bicep.Decompiler.IntegrationTests/Working/issue2380/main.bicep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
targetScope = 'managementGroup' | ||
|
||
@description('EnrollmentAccount used for subscription billing') | ||
param enrollmentAccount string | ||
|
||
@description('BillingAccount used for subscription billing') | ||
param billingAccount string | ||
|
||
@description('Alias to assign to the subscription') | ||
param subscriptionAlias string | ||
|
||
@description('Display name for the subscription') | ||
param subscriptionDisplayName string | ||
|
||
@allowed([ | ||
'Production' | ||
'DevTest' | ||
]) | ||
@description('Workload type for the subscription') | ||
param subscriptionWorkload string = 'Production' | ||
|
||
resource subscriptionAlias_resource 'Microsoft.Subscription/aliases@2020-09-01' = { | ||
//@[82:333) [BCP135 (Error)] Scope "managementGroup" is not valid for this resource type. Permitted scopes: "tenant". |{\n name: subscriptionAlias\n properties: {\n workload: subscriptionWorkload\n displayName: subscriptionDisplayName\n billingScope: tenantResourceId('Microsoft.Billing/billingAccounts/enrollmentAccounts', billingAccount, enrollmentAccount)\n }\n}| | ||
name: subscriptionAlias | ||
properties: { | ||
workload: subscriptionWorkload | ||
displayName: subscriptionDisplayName | ||
billingScope: tenantResourceId('Microsoft.Billing/billingAccounts/enrollmentAccounts', billingAccount, enrollmentAccount) | ||
} | ||
} | ||
|
||
output subscriptionId string = subscriptionAlias_resource.properties.subscriptionId |
60 changes: 60 additions & 0 deletions
60
src/Bicep.Decompiler.IntegrationTests/Working/issue2380/main.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"enrollmentAccount": { | ||
"type": "string", | ||
"metadata": { | ||
"description": "EnrollmentAccount used for subscription billing" | ||
} | ||
}, | ||
"billingAccount": { | ||
"type": "string", | ||
"metadata": { | ||
"description": "BillingAccount used for subscription billing" | ||
} | ||
}, | ||
"subscriptionAlias": { | ||
"type": "string", | ||
"metadata": { | ||
"description": "Alias to assign to the subscription" | ||
} | ||
}, | ||
"subscriptionDisplayName": { | ||
"type": "string", | ||
"metadata": { | ||
"description": "Display name for the subscription" | ||
} | ||
}, | ||
"subscriptionWorkload": { | ||
"type": "string", | ||
"defaultValue": "Production", | ||
"allowedValues": [ | ||
"Production", | ||
"DevTest" | ||
], | ||
"metadata": { | ||
"description": "Workload type for the subscription" | ||
} | ||
} | ||
}, | ||
"resources": [ | ||
{ | ||
//"scope": "/", | ||
"name": "[parameters('subscriptionAlias')]", | ||
"type": "Microsoft.Subscription/aliases", | ||
"apiVersion": "2020-09-01", | ||
"properties": { | ||
"workload": "[parameters('subscriptionWorkload')]", | ||
"displayName": "[parameters('subscriptionDisplayName')]", | ||
"billingScope": "[tenantResourceId('Microsoft.Billing/billingAccounts/enrollmentAccounts', parameters('billingAccount'), parameters('enrollmentAccount'))]" | ||
} | ||
} | ||
], | ||
"outputs": { | ||
"subscriptionId": { | ||
"type": "string", | ||
"value": "[reference(parameters('subscriptionAlias')).subscriptionId]" | ||
} | ||
} | ||
} |
Oops, something went wrong.