Skip to content

Commit

Permalink
feat: or-2012 do not load temporary vertegenwoordigers on production
Browse files Browse the repository at this point in the history
  • Loading branch information
QuintenGreenstack committed Dec 11, 2023
1 parent 380988a commit 935b7a7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<TemporaryMagdaVertegenwoordigersSection>(vertegenwoordigersJson);

Check warning on line 100 in src/AssociationRegistry.Admin.Api/Infrastructure/Extensions/ConfigurationExtensions.cs

View workflow job for this annotation

GitHub Actions / Build Admin Api / build-image

Possible null reference argument for parameter 'value' in 'TemporaryMagdaVertegenwoordigersSection? JsonConvert.DeserializeObject<TemporaryMagdaVertegenwoordigersSection>(string value)'.

Check warning on line 100 in src/AssociationRegistry.Admin.Api/Infrastructure/Extensions/ConfigurationExtensions.cs

View workflow job for this annotation

GitHub Actions / Build Admin Api / build-image

Possible null reference argument for parameter 'value' in 'TemporaryMagdaVertegenwoordigersSection? JsonConvert.DeserializeObject<TemporaryMagdaVertegenwoordigersSection>(string value)'.

Expand Down
4 changes: 3 additions & 1 deletion src/AssociationRegistry.Admin.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<AppSettings>();

builder.Services

Check warning on line 290 in src/AssociationRegistry.Admin.Api/Program.cs

View workflow job for this annotation

GitHub Actions / Build Admin Projections / build-image

The type 'AssociationRegistry.Admin.Api.Infrastructure.ConfigurationBindings.AppSettings?' cannot be used as type parameter 'TService' in the generic type or method 'ServiceCollectionServiceExtensions.AddSingleton<TService>(IServiceCollection, TService)'. Nullability of type argument 'AssociationRegistry.Admin.Api.Infrastructure.ConfigurationBindings.AppSettings?' doesn't match 'class' constraint.
Expand Down

0 comments on commit 935b7a7

Please sign in to comment.