2026-06-09 06:41:28 +03:30
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using Microsoft.AspNetCore.Routing;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2026-06-09 18:34:53 +03:30
|
|
|
using TeamUp.Modules.Integrations.Git;
|
|
|
|
|
using TeamUp.SharedKernel.Git;
|
2026-06-09 06:41:28 +03:30
|
|
|
using TeamUp.SharedKernel.Modularity;
|
|
|
|
|
|
|
|
|
|
namespace TeamUp.Modules.Integrations;
|
|
|
|
|
|
2026-06-09 18:34:53 +03:30
|
|
|
/// <summary>
|
|
|
|
|
/// BYOK API configs, the Git connection, the encrypted-credential store. In M2 it provides the
|
|
|
|
|
/// <see cref="IGitProvider"/> (filesystem for dogfood, Gitea over REST). BYOK lands in M3.
|
|
|
|
|
/// </summary>
|
2026-06-09 06:41:28 +03:30
|
|
|
public sealed class IntegrationsModule : IModule
|
|
|
|
|
{
|
|
|
|
|
public string Name => "integrations";
|
|
|
|
|
|
|
|
|
|
public void Register(IServiceCollection services, IConfiguration configuration)
|
|
|
|
|
{
|
2026-06-09 18:34:53 +03:30
|
|
|
services.Configure<GitSourceOptions>(configuration.GetSection(GitSourceOptions.SectionName));
|
|
|
|
|
var options = configuration.GetSection(GitSourceOptions.SectionName).Get<GitSourceOptions>() ?? new GitSourceOptions();
|
|
|
|
|
|
|
|
|
|
if (string.Equals(options.Provider, "gitea", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
services.AddHttpClient<IGitProvider, GiteaGitProvider>();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
services.AddSingleton<IGitProvider, FileSystemGitProvider>();
|
|
|
|
|
}
|
2026-06-09 06:41:28 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void MapEndpoints(IEndpointRouteBuilder endpoints)
|
|
|
|
|
{
|
|
|
|
|
endpoints.MapGroup($"/api/{Name}")
|
|
|
|
|
.WithTags("Integrations")
|
|
|
|
|
.MapGet("/ping", () => TypedResults.Ok(new ModulePing(Name)));
|
|
|
|
|
}
|
|
|
|
|
}
|