-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
Encamina.Enmarcha.Aspire
project
- Loading branch information
1 parent
c48b949
commit bda7776
Showing
5 changed files
with
93 additions
and
1 deletion.
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
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
19 changes: 19 additions & 0 deletions
19
src/Encamina.Enmarcha.Aspire/Encamina.Enmarcha.Aspire.csproj
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,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<PackageReadmeFile>README.md</PackageReadmeFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Aspire.Hosting" Version="8.2.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="README.md" Pack="true" PackagePath="\" /> | ||
</ItemGroup> | ||
|
||
</Project> |
31 changes: 31 additions & 0 deletions
31
src/Encamina.Enmarcha.Aspire/Extensions/ResourceBuilderExtensions.cs
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,31 @@ | ||
using Aspire.Hosting; | ||
using Aspire.Hosting.ApplicationModel; | ||
|
||
using Encamina.Enmarcha.Aspire.Extensions; | ||
|
||
namespace Encamina.Enmarcha.Aspire.Extensions; | ||
|
||
/// <summary> | ||
/// Provides extension methods for configuring Aspire resources. | ||
/// </summary> | ||
public static class ResourceBuilderExtensions | ||
{ | ||
/// <summary> | ||
/// Adds an environment variable array to the resource. | ||
/// </summary> | ||
/// <typeparam name="T">The resource type.</typeparam> | ||
/// <param name="builder">The resource builder.</param> | ||
/// <param name="name">The name of the environment variable.</param> | ||
/// <param name="values">The array of values of the environment variable.</param> | ||
/// <returns>A resource configured with the specified environment variable.</returns> | ||
public static IResourceBuilder<T> WithEnvironment<T>(this IResourceBuilder<T> builder, string name, string[] values) where T : IResourceWithEnvironment | ||
{ | ||
return builder.WithEnvironment(context => | ||
{ | ||
for (var i = 0; i < values.Length; i++) | ||
{ | ||
context.EnvironmentVariables[$"{name}:{i}"] = values[i]; | ||
} | ||
}); | ||
} | ||
} |
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,30 @@ | ||
# Enmarcha Aspire | ||
|
||
[](https://www.nuget.org/packages/Encamina.Enmarcha.Aspire) | ||
|
||
Aspire Resource Builder Extensions is a set of tools designed to simplify the configuration of cloud-native resources with environment variables. This package is ideal for projects that need to manage distributed application resources in a cloud environment using environment-specific configurations. | ||
|
||
## Setup | ||
|
||
### Nuget package | ||
|
||
First, [install NuGet](http://docs.nuget.org/docs/start-here/installing-nuget). Then, install [Encamina.Enmarcha.Aspire](https://www.nuget.org/packages/Encamina.Enmarcha.Aspire) from the package manager console: | ||
|
||
PM> Install-Package Encamina.Enmarcha.Aspire | ||
|
||
### .NET CLI: | ||
|
||
[Install .NET CLI](https://learn.microsoft.com/en-us/dotnet/core/tools/). Next, install [Encamina.Enmarcha.Aspire](https://www.nuget.org/packages/Encamina.Enmarcha.Aspire) from the .NET CLI: | ||
|
||
dotnet add package Encamina.Enmarcha.Aspire | ||
|
||
## How to use | ||
|
||
### Resource Builder Extensions | ||
|
||
The `ResourceBuilderExtensions` class provides a set of extension methods to configure Aspire resources. | ||
|
||
```csharp | ||
var agentProjects = builder.AddProject<Projects.AgentProjects>(appIdProjects) | ||
.WithEnvironment(Constants.Settings.Options.PendingTaskStatuses, pendingTaskStatuses) | ||
``` |