audit, advisories and doctors/setup work
This commit is contained in:
51
src/Tools/GoldenPairs/Services/GoldenPairsServiceFactory.cs
Normal file
51
src/Tools/GoldenPairs/Services/GoldenPairsServiceFactory.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using StellaOps.Scanner.Analyzers.Native;
|
||||
using StellaOps.Tools.GoldenPairs.Schema;
|
||||
|
||||
namespace StellaOps.Tools.GoldenPairs.Services;
|
||||
|
||||
public static class GoldenPairsServiceFactory
|
||||
{
|
||||
public static ServiceProvider Build(
|
||||
string datasetRoot,
|
||||
string metadataSchemaPath,
|
||||
string indexSchemaPath)
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
|
||||
services.AddLogging(builder =>
|
||||
{
|
||||
builder.AddSimpleConsole(options =>
|
||||
{
|
||||
options.SingleLine = true;
|
||||
options.TimestampFormat = "HH:mm:ss ";
|
||||
});
|
||||
builder.SetMinimumLevel(LogLevel.Information);
|
||||
});
|
||||
|
||||
services.AddHttpClient("golden-pairs-mirror");
|
||||
|
||||
var layout = new GoldenPairLayout(datasetRoot);
|
||||
services.AddSingleton(layout);
|
||||
|
||||
var schemaProvider = new GoldenPairsSchemaProvider(metadataSchemaPath, indexSchemaPath);
|
||||
services.AddSingleton(schemaProvider);
|
||||
|
||||
services.AddSingleton<IElfSectionHashExtractor>(sp =>
|
||||
{
|
||||
var timeProvider = sp.GetRequiredService<TimeProvider>();
|
||||
var options = Options.Create(new ElfSectionHashOptions());
|
||||
return new ElfSectionHashExtractor(timeProvider, options);
|
||||
});
|
||||
|
||||
services.AddSingleton<GoldenPairLoader>();
|
||||
services.AddSingleton<ISectionHashProvider, FileSectionHashProvider>();
|
||||
services.AddSingleton<TimeProvider>(TimeProvider.System);
|
||||
services.AddSingleton<IDiffPipelineService, DiffPipelineService>();
|
||||
services.AddSingleton<IPackageMirrorService, AptPackageMirrorService>();
|
||||
|
||||
return services.BuildServiceProvider();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user