diff --git a/src/Shawarma.Aspire.Hosting/KnownShawarmaCommands.cs b/src/Shawarma.Aspire.Hosting/KnownShawarmaCommands.cs new file mode 100644 index 0000000..e7797b4 --- /dev/null +++ b/src/Shawarma.Aspire.Hosting/KnownShawarmaCommands.cs @@ -0,0 +1,17 @@ +namespace Shawarma.Aspire.Hosting; + +/// +/// Known Aspire command names for Shawarma Aspire services. +/// +public static class KnownShawarmaCommands +{ + /// + /// The command name for enabling Shawarma services. + /// + public const string EnableShawarma = "enable-shawarma"; + + /// + /// The command name for disabling Shawarma services. + /// + public const string DisableShawarma = "disable-shawarma"; +} diff --git a/src/Shawarma.Aspire.Hosting/ShawarmaResourceBuilderExtensions.cs b/src/Shawarma.Aspire.Hosting/ShawarmaResourceBuilderExtensions.cs index e76c72c..7d241b9 100644 --- a/src/Shawarma.Aspire.Hosting/ShawarmaResourceBuilderExtensions.cs +++ b/src/Shawarma.Aspire.Hosting/ShawarmaResourceBuilderExtensions.cs @@ -11,9 +11,6 @@ namespace Shawarma.Aspire.Hosting; /// public static class ShawarmaResourceBuilderExtensions { - private const string EnableShawarmaCommandName = "enableShawarma"; - private const string DisableShawarmaCommandName = "disableShawarma"; - private static readonly string[] s_httpSchemes = ["https", "http"]; private static Func NamedEndpointSelector(IResourceBuilder builder, string endpointName) @@ -141,7 +138,7 @@ await notificationService.PublishUpdateAsync(builder.Resource, path: options.ApplicationStatePath, displayName: "Start Shawarma Services", endpointSelector: endpointSelector, - commandName: EnableShawarmaCommandName, + commandName: KnownShawarmaCommands.EnableShawarma, commandOptions: new HttpCommandOptions { Method = HttpMethod.Post, @@ -179,7 +176,7 @@ await notificationService.PublishUpdateAsync(builder.Resource, path: options.ApplicationStatePath, displayName: "Stop Shawarma Services", endpointSelector: endpointSelector, - commandName: DisableShawarmaCommandName, + commandName: KnownShawarmaCommands.DisableShawarma, commandOptions: new HttpCommandOptions { Method = HttpMethod.Post, @@ -224,7 +221,7 @@ await notificationService.PublishUpdateAsync(resource, { var commandService = e.Services.GetRequiredService(); - var result = await commandService.ExecuteCommandAsync(resource, EnableShawarmaCommandName, cancellationToken); + var result = await commandService.ExecuteCommandAsync(resource, KnownShawarmaCommands.EnableShawarma, cancellationToken); if (result is { Success: false, Canceled: false }) { throw new InvalidOperationException($"Failed to enable Shawarma services on startup: {result.ErrorMessage}");