OPC # 0001: Extract Clarity into standalone repo

This commit is contained in:
amadzarak
2026-04-25 17:26:35 -04:00
commit 60821e219c
65 changed files with 10203 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
using Minio;
using Minio.DataModel.Args;
namespace Clarity.Server.Extensions;
public static class MinioExtensions
{
/// <summary>
/// Idempotently provisions MinIO buckets on application startup.
/// </summary>
public static async Task ProvisionBucketsAsync(this WebApplication app, params string[] bucketNames)
{
// Skip entirely if Minio isn't configured (e.g. tenant containers without Minio env var)
var connStr = app.Configuration.GetConnectionString("minio");
if (string.IsNullOrWhiteSpace(connStr)) return;
using var scope = app.Services.CreateScope();
var minioClient = scope.ServiceProvider.GetRequiredService<IMinioClient>();
var logger = scope.ServiceProvider.GetRequiredService<ILogger<Program>>();
foreach (var bucket in bucketNames)
{
try
{
var exists = await minioClient.BucketExistsAsync(new BucketExistsArgs().WithBucket(bucket));
if (!exists)
{
await minioClient.MakeBucketAsync(new MakeBucketArgs().WithBucket(bucket));
logger.LogInformation("🚀 Project Clarity: Successfully provisioned MinIO bucket '{Bucket}'", bucket);
}
}
catch (Exception ex)
{
logger.LogError(ex, "❌ Project Clarity: Failed to provision MinIO bucket '{Bucket}'", bucket);
}
}
}
}