diff --git a/src/AssociationRegistry.Admin.Api/Infrastructure/Extensions/ConfigurationExtensions.cs b/src/AssociationRegistry.Admin.Api/Infrastructure/Extensions/ConfigurationExtensions.cs index 37cbea038..01ea8e386 100644 --- a/src/AssociationRegistry.Admin.Api/Infrastructure/Extensions/ConfigurationExtensions.cs +++ b/src/AssociationRegistry.Admin.Api/Infrastructure/Extensions/ConfigurationExtensions.cs @@ -3,7 +3,9 @@ namespace AssociationRegistry.Admin.Api.Infrastructure.Extensions; using AssociationRegistry.Magda.Configuration; using ConfigurationBindings; using Framework; +using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; using Newtonsoft.Json; using Serilog; using System; @@ -85,8 +87,15 @@ public static MagdaOptionsSection GetMagdaOptionsSection( public static TemporaryMagdaVertegenwoordigersSection GetMagdaTemporaryVertegenwoordigersSection( this IConfiguration configuration, + IWebHostEnvironment environment, string magdaOptionsSectionName = TemporaryMagdaVertegenwoordigersSection.SectionName) { + if (environment.IsProduction()) + { + Log.Logger.Information("Not loading temporary vertegenwoordigers in Production"); + return new TemporaryMagdaVertegenwoordigersSection(); + } + var vertegenwoordigersJson = configuration[magdaOptionsSectionName]; var temporaryVertegenwoordigers = JsonConvert.DeserializeObject(vertegenwoordigersJson); diff --git a/src/AssociationRegistry.Admin.Api/Program.cs b/src/AssociationRegistry.Admin.Api/Program.cs index 612c91fc5..f9cbad68d 100755 --- a/src/AssociationRegistry.Admin.Api/Program.cs +++ b/src/AssociationRegistry.Admin.Api/Program.cs @@ -46,6 +46,7 @@ namespace AssociationRegistry.Admin.Api; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Diagnostics.HealthChecks; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Localization; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -282,7 +283,8 @@ private static void ConfigureServices(WebApplicationBuilder builder) var elasticSearchOptionsSection = builder.Configuration.GetElasticSearchOptionsSection(); var postgreSqlOptionsSection = builder.Configuration.GetPostgreSqlOptionsSection(); var magdaOptionsSection = builder.Configuration.GetMagdaOptionsSection(); - var magdaTemporaryVertegenwoordigersSection = builder.Configuration.GetMagdaTemporaryVertegenwoordigersSection(); + + var magdaTemporaryVertegenwoordigersSection = builder.Configuration.GetMagdaTemporaryVertegenwoordigersSection(builder.Environment); var appSettings = builder.Configuration.Get(); builder.Services