Skip to content
Merged
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
30 changes: 24 additions & 6 deletions src/Shawarma.Aspire.Hosting/ShawarmaResourceBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,43 @@ private static Func<EndpointReference> NamedEndpointSelector<TResource>(IResourc
extension<T>(IResourceBuilder<T> builder)
where T : IResourceWithEndpoints
{
/// <summary>
/// Add commands to enable and disable Shawarma services for the resource.
/// </summary>
/// <param name="autoStart">Automatically enable Shawarma services when the resource is ready.</param>
/// <returns>The <see cref="IResourceBuilder{T}"/>.</returns>
public IResourceBuilder<T> WithShawarma(bool autoStart = false) =>
builder.WithShawarma(null, autoStart);

/// <summary>
/// Add commands to enable and disable Shawarma services for the resource.
/// </summary>
/// <param name="options">Optional configuration for Shawarma.</param>
/// <returns>The <see cref="IResourceBuilder{T}"/>.</returns>
public IResourceBuilder<T> WithShawarma(ShawarmaOptions? options) =>
builder.WithShawarma((Func<EndpointReference>?)null, options);

/// <summary>
/// Add commands to enable and disable Shawarma services for the resource.
/// </summary>
/// <param name="endpointName">The name of the HTTP endpoint on this resource to send the request to when the command is invoked.</param>
/// <param name="autoStart">Automatically enable Shawarma services when the resource is ready.</param>
/// <returns>The <see cref="IResourceBuilder{T}"/>.</returns>
public IResourceBuilder<T> WithShawarma([EndpointName] string? endpointName = null, bool autoStart = false) =>
builder.WithShawarma(endpointName, new ShawarmaOptions()
{
AutoStart = autoStart
});
public IResourceBuilder<T> WithShawarma([EndpointName] string? endpointName, bool autoStart = false) =>
builder.WithShawarma(endpointName, autoStart
? new ShawarmaOptions()
{
AutoStart = true
}
: ShawarmaOptions.Default);

/// <summary>
/// Add commands to enable and disable Shawarma services for the resource.
/// </summary>
/// <param name="endpointName">The name of the HTTP endpoint on this resource to send the request to when the command is invoked.</param>
/// <param name="options">Optional configuration for Shawarma.</param>
/// <returns>The <see cref="IResourceBuilder{T}"/>.</returns>
public IResourceBuilder<T> WithShawarma([EndpointName] string? endpointName = null, ShawarmaOptions? options = null) =>
public IResourceBuilder<T> WithShawarma([EndpointName] string? endpointName, ShawarmaOptions? options) =>
builder.WithShawarma(
endpointSelector: endpointName is not null
? NamedEndpointSelector(builder, endpointName)
Expand Down