Skip to content

Commit

Permalink
Fixed invalid SmtpServer section name
Browse files Browse the repository at this point in the history
  • Loading branch information
cjoergensen committed Oct 30, 2023
1 parent 1d8a35e commit 7021c4f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Kibana.Alerts/ConfigurationValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private static void EnsureAtLeastOneConnectorType(IConfiguration connectorsSecti
{
if (!connectorsSection.GetSection("Smtp").Exists() && !connectorsSection.GetSection("MsTeams").Exists())
{
throw new Exception($"For Group '{groupName}', at least one connector of type 'Smtp' or 'MsTeams' is required.");
throw new Exception($"Group '{groupName}' needs at least one connector of type 'Smtp' or 'MsTeams'.");
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/Kibana.Alerts/Connectors/SmtpConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public sealed class SmtpConnector(IConfiguration configuration, IHandlebars hand

public async Task Send(Alert alert, IConfigurationSection configurationSection, CancellationToken cancellationToken = default)
{
var port = int.Parse(configuration["Smtp:Port"]);
var host = configuration["Smtp:Host"];
var sender = configuration["Smtp:Sender"];
var port = int.Parse(configuration["SmtpServer:Port"]);
var host = configuration["SmtpServer:Host"];
var sender = configuration["SmtpServer:Sender"];

var settings = new SmtpSettings();
configurationSection.Bind(settings);
Expand Down
9 changes: 2 additions & 7 deletions src/Kibana.Alerts/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@
var builder = Host.CreateApplicationBuilder(args);
builder.Configuration.AddJsonFile("groups.json", optional: true, reloadOnChange: true);
builder.Configuration.AddJsonFile("connectors.json", optional: true, reloadOnChange: true);

ConfigurationValidator.ValidateConfiguration(builder.Configuration);



builder.Services.AddHostedService<Worker>();


builder.Services.AddSingleton(factory =>
{
var handlebars = Handlebars.Create();
Expand All @@ -27,7 +22,7 @@

builder.Services.AddHttpClient<IConnector, MsTeamsConnector>();
builder.Services.AddKeyedTransient<IConnector, MsTeamsConnector>("msteams");

builder.Services.AddSingleton<ConnectorFactory>();

var host = builder.Build();
host.Run();
host.Run();

0 comments on commit 7021c4f

Please sign in to comment.