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

Use fully qualified symbolic name to refer to copy loop in dependsOn #16236

Merged
merged 3 commits into from
Jan 28, 2025
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
26 changes: 26 additions & 0 deletions src/Bicep.Core.IntegrationTests/ScenarioTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6777,4 +6777,30 @@ param name string

result.ExcludingDiagnostics("use-safe-access").Should().NotHaveAnyDiagnostics();
}

[TestMethod]
public void Test_Issue16230()
{
var result = CompilationHelper.Compile("""
resource identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' existing = {
name: 'foo'

resource federation 'federatedIdentityCredentials' = [for i in range(0, 10): {
name: 'fed_${i}'
}]
}

resource otherIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
name: 'bar'
location: resourceGroup().location
dependsOn: [
identity::federation
]
}
""");

result.Should().NotHaveAnyCompilationBlockingDiagnostics();
result.Template.Should().NotBeNull();
result.Template.Should().HaveJsonAtPath("$.resources[?(@.name == 'bar')].dependsOn", "[\"identity::federation\"]");
}
}
4 changes: 2 additions & 2 deletions src/Bicep.Core/Emit/TemplateWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1565,8 +1565,8 @@ private static void EmitClassicDependsOnEntry(ExpressionEmitter emitter, Resourc
if (resource.Symbol.IsCollection && reference.IndexContext?.Index is null)
{
// dependency is on the entire resource collection
// write the name of the resource collection as the dependency
emitter.EmitExpression(new StringLiteralExpression(null, resource.Symbol.DeclaringResource.Name.IdentifierName));
// write the fully qualified name of the resource collection (this is the name of the copy loop) as the dependency
emitter.EmitSymbolReference(resource);

break;
}
Expand Down
Loading