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

Prepare for release #43285

Merged
merged 3 commits into from
Apr 9, 2024
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
1 change: 0 additions & 1 deletion eng/Packages.Data.props
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@
<PackageReference Update="Azure.Monitor.OpenTelemetry.LiveMetrics" Version="1.0.0-beta.3" />
<PackageReference Update="Azure.Monitor.Query" Version="1.1.0" />
<PackageReference Update="Azure.Identity" Version="1.10.4" />
<PackageReference Update="Azure.Provisioning" Version="0.2.0-beta.1" />
<PackageReference Update="Azure.Security.KeyVault.Secrets" Version="4.2.0" />
<PackageReference Update="Azure.Security.KeyVault.Keys" Version="4.2.0" />
<PackageReference Update="Azure.Security.KeyVault.Certificates" Version="4.2.0" />
Expand Down
8 changes: 2 additions & 6 deletions sdk/provisioning/Azure.Provisioning/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# Release History

## 0.2.0-beta.2 (Unreleased)
## 0.2.0-beta.2 (2024-04-09)

### Features Added

### Breaking Changes

### Bugs Fixed

### Other Changes
- Added `AddDependency` method.

## 0.2.0-beta.1 (2024-04-04)

Expand Down
2 changes: 1 addition & 1 deletion sdk/provisioning/Azure.Provisioning/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/provisioning/Azure.Provisioning",
"Tag": "net/provisioning/Azure.Provisioning_3336ebb5fd"
"Tag": "net/provisioning/Azure.Provisioning_5f8802b96f"
}
19 changes: 8 additions & 11 deletions sdk/provisioning/Azure.Provisioning/src/ModuleInfrastructure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ public void Write(string? outputPath = null)
outputPath ??= $".\\{GetType().Name}";
outputPath = Path.GetFullPath(outputPath);

WriteBicepFile(_rootConstruct, outputPath);
if (_rootConstruct == null)
{
return;
throw new InvalidOperationException("No resources were added to the Infrastructure. Add resources to the Infrastructure before calling Build.");
}

WriteBicepFile(_rootConstruct, outputPath);

var queue = new Queue<ModuleConstruct>();
queue.Enqueue(_rootConstruct!);
queue.Enqueue(_rootConstruct);
WriteConstructsByLevel(queue, outputPath);
}

Expand Down Expand Up @@ -194,21 +195,17 @@ private void WriteConstructsByLevel(Queue<ModuleConstruct> constructs, string ou
}
}

private string GetFilePath(ModuleConstruct? construct, string outputPath)
private string GetFilePath(ModuleConstruct construct, string outputPath)
{
string fileName = construct == null || construct.IsRoot ? Path.Combine(outputPath, "main.bicep") : Path.Combine(outputPath, "resources", construct.Name, $"{construct.Name}.bicep");
string fileName = construct.IsRoot ? Path.Combine(outputPath, "main.bicep") : Path.Combine(outputPath, "resources", construct.Name, $"{construct.Name}.bicep");
Directory.CreateDirectory(Path.GetDirectoryName(fileName)!);
return fileName;
}

private void WriteBicepFile(ModuleConstruct? construct, string outputPath)
private void WriteBicepFile(ModuleConstruct construct, string outputPath)
{
using var stream = new FileStream(GetFilePath(construct, outputPath), FileMode.Create);
// just create an empty file if there is no construct
if (construct == null)
{
return;
}

#if NET6_0_OR_GREATER
stream.Write(construct.SerializeModule());
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,11 @@ public async Task DependentResources()
await ValidateBicepAsync(interactiveMode: true);
}

[RecordedTest]
public async Task EmptyConstructDoesNotThrow()
[Test]
public void EmptyConstructThrows()
{
TestInfrastructure infra = new TestInfrastructure();
infra.Build(GetOutputPath());
await ValidateBicepAsync();
Assert.Throws<InvalidOperationException>(() => infra.Build(GetOutputPath()));
}

[RecordedTest]
Expand Down