using System.Diagnostics.CodeAnalysis; using Azure.ResourceManager; using JetBrains.Annotations; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Proto.Cluster.AzureContainerApps.Stores.ResourceTags; namespace Proto.Cluster.AzureContainerApps; /// /// Adds extension methods to for registering the Azure Container Apps provider /// [PublicAPI] public static class ServiceCollectionExtensions { /// /// Adds the Azure Container Apps provider to the service collection. /// /// The service collection to add the provider to. /// An to create instances. /// An optional configuration for the member store. /// An optional action to configure the provider options. /// The service collection. public static IServiceCollection AddAzureContainerAppsProvider(this IServiceCollection services, IArmClientProvider? armClientProvider = default, Action? configureMemberStore = null, Action? configure = null) { var configureOptions = configure ?? (_ => { }); services.Configure(configureOptions); services.ConfigureOptions(); services.AddSingleton(); if (armClientProvider != null) services.AddSingleton(armClientProvider); if (configureMemberStore != null) configureMemberStore.Invoke(services); else services.AddResourceTagsMemberStore(); return services; } }