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

Decompile reference() functions with resource name references #2381

Merged
merged 3 commits into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void Decompiler_generates_expected_bicep_files_with_diagnostics(ExampleDa
var diagnostics = diagnosticsBySyntaxTree[syntaxTree];
var bicepOutput = filesToSave[syntaxTree.FileUri];

var sourceTextWithDiags = OutputHelper.AddDiagsToSourceText(bicepOutput, Environment.NewLine, diagnostics, diag => OutputHelper.GetDiagLoggingString(bicepOutput, outputDirectory, diag));
var sourceTextWithDiags = OutputHelper.AddDiagsToSourceText(bicepOutput, "\n", diagnostics, diag => OutputHelper.GetDiagLoggingString(bicepOutput, outputDirectory, diag));
File.WriteAllText(syntaxTree.FileUri.LocalPath + ".actual", sourceTextWithDiags);

sourceTextWithDiags.Should().EqualWithLineByLineDiffOutput(
Expand Down
32 changes: 32 additions & 0 deletions src/Bicep.Decompiler.IntegrationTests/Working/issue2380/main.bicep
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 src/Bicep.Decompiler.IntegrationTests/Working/issue2380/main.json
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]"
}
}
}
Loading