39 lines
1.6 KiB
C#
39 lines
1.6 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
using StellaOps.AirGap.Controller.Options;
|
|
using StellaOps.AirGap.Controller.Services;
|
|
using StellaOps.AirGap.Controller.Stores;
|
|
using StellaOps.AirGap.Importer.Validation;
|
|
using StellaOps.AirGap.Time.Services;
|
|
|
|
namespace StellaOps.AirGap.Controller.DependencyInjection;
|
|
|
|
public static class AirGapControllerServiceCollectionExtensions
|
|
{
|
|
public static IServiceCollection AddAirGapController(this IServiceCollection services, IConfiguration configuration)
|
|
{
|
|
services.Configure<AirGapStartupOptions>(configuration.GetSection("AirGap:Startup"));
|
|
services.Configure<AirGapTelemetryOptions>(configuration.GetSection("AirGap:Telemetry"));
|
|
|
|
services.AddSingleton<AirGapTelemetry>();
|
|
services.AddSingleton<StalenessCalculator>();
|
|
services.AddSingleton<AirGapStateService>();
|
|
services.AddSingleton<TufMetadataValidator>();
|
|
services.AddSingleton<RootRotationPolicy>();
|
|
services.AddSingleton<ReplayVerifier>();
|
|
services.AddSingleton<ReplayVerificationService>();
|
|
|
|
services.AddSingleton<IAirGapStateStore>(sp =>
|
|
{
|
|
var logger = sp.GetRequiredService<ILogger<InMemoryAirGapStateStore>>();
|
|
logger.LogWarning("AirGap controller using in-memory state store; state resets on process restart.");
|
|
return new InMemoryAirGapStateStore();
|
|
});
|
|
|
|
services.AddHostedService<AirGapStartupDiagnosticsHostedService>();
|
|
|
|
return services;
|
|
}
|
|
}
|