diff --git a/KeyVault.Acmebot/Internal/Constants.cs b/KeyVault.Acmebot/Internal/Constants.cs index dcb06cb..b30fbf1 100644 --- a/KeyVault.Acmebot/Internal/Constants.cs +++ b/KeyVault.Acmebot/Internal/Constants.cs @@ -1,9 +1,12 @@ -using System.Reflection; +using System; +using System.Reflection; namespace KeyVault.Acmebot.Internal; internal static class Constants { + public static string FunctionAppName { get; } = Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME") ?? "Unknown"; + public static string ApplicationVersion { get; } = typeof(Startup).Assembly .GetCustomAttribute() ?.InformationalVersion; diff --git a/KeyVault.Acmebot/Internal/GenericPayloadBuilder.cs b/KeyVault.Acmebot/Internal/GenericPayloadBuilder.cs index 4d918c1..8bcc3a9 100644 --- a/KeyVault.Acmebot/Internal/GenericPayloadBuilder.cs +++ b/KeyVault.Acmebot/Internal/GenericPayloadBuilder.cs @@ -1,10 +1,19 @@ using System; using System.Collections.Generic; +using KeyVault.Acmebot.Options; + namespace KeyVault.Acmebot.Internal; internal class GenericPayloadBuilder : IWebhookPayloadBuilder { + public GenericPayloadBuilder(AcmebotOptions options) + { + _options = options; + } + + private readonly AcmebotOptions _options; + public object BuildCompleted(string certificateName, DateTimeOffset? expirationDate, IEnumerable dnsNames, string acmeEndpoint) { return new @@ -12,7 +21,9 @@ public object BuildCompleted(string certificateName, DateTimeOffset? expirationD certificateName, expirationDate, dnsNames, - acmeEndpoint + acmeEndpoint, + keyVaultName = new Uri(_options.VaultBaseUrl).Host, + functionAppName = Constants.FunctionAppName }; } @@ -21,7 +32,9 @@ public object BuildFailed(string functionName, string reason) return new { functionName, - reason + reason, + keyVaultName = new Uri(_options.VaultBaseUrl).Host, + functionAppName = Constants.FunctionAppName }; } } diff --git a/KeyVault.Acmebot/Startup.cs b/KeyVault.Acmebot/Startup.cs index 874804d..b96f9e8 100644 --- a/KeyVault.Acmebot/Startup.cs +++ b/KeyVault.Acmebot/Startup.cs @@ -89,7 +89,7 @@ public override void Configure(IFunctionsHostBuilder builder) if (options.Webhook is null) { - return new GenericPayloadBuilder(); + return new GenericPayloadBuilder(options); } if (options.Webhook.Host.EndsWith("hooks.slack.com", StringComparison.OrdinalIgnoreCase)) @@ -102,7 +102,7 @@ public override void Configure(IFunctionsHostBuilder builder) return new TeamsPayloadBuilder(); } - return new GenericPayloadBuilder(); + return new GenericPayloadBuilder(options); }); // Add DNS Providers