using System;
using Microsoft.Extensions.DependencyInjection;
using StellaOps.Feedser.Storage.Mongo.Advisories;
using StellaOps.Plugin;

namespace StellaOps.Feedser.Exporter.TrivyDb;

public sealed class TrivyDbExporterPlugin : IExporterPlugin
{
    public string Name => TrivyDbFeedExporter.ExporterName;

    public bool IsAvailable(IServiceProvider services)
    {
        ArgumentNullException.ThrowIfNull(services);
        return services.GetService<IAdvisoryStore>() is not null;
    }

    public IFeedExporter Create(IServiceProvider services)
    {
        ArgumentNullException.ThrowIfNull(services);
        return ActivatorUtilities.CreateInstance<TrivyDbFeedExporter>(services);
    }
}
