OPC # 0001: Extract OPC into standalone repo
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
using ControlPlane.Core.Config;
|
||||
using ControlPlane.Core.Interfaces;
|
||||
using ControlPlane.Core.Services;
|
||||
using ControlPlane.Worker;
|
||||
using ControlPlane.Worker.Services;
|
||||
using ControlPlane.Worker.Steps;
|
||||
using Keycloak.AuthServices.Sdk;
|
||||
using MassTransit;
|
||||
|
||||
var builder = Host.CreateApplicationBuilder(args);
|
||||
|
||||
builder.AddServiceDefaults();
|
||||
|
||||
// Centralized infrastructure options — domain, network, internal URLs, cert paths
|
||||
builder.Services.Configure<ClarityInfraOptions>(
|
||||
builder.Configuration.GetSection(ClarityInfraOptions.Section));
|
||||
|
||||
// Keycloak Admin SDK client
|
||||
builder.Services.AddKeycloakAdminHttpClient(o =>
|
||||
{
|
||||
o.AuthServerUrl = builder.Configuration["Keycloak:AuthServerUrl"] ?? "http://localhost:8080";
|
||||
o.Realm = builder.Configuration["Keycloak:Realm"] ?? "master";
|
||||
o.Resource = builder.Configuration["Keycloak:Resource"] ?? "admin-cli";
|
||||
});
|
||||
|
||||
// Custom admin client - handles realm creation, roles, role assignment (not in SDK)
|
||||
builder.Services.AddSingleton<KeycloakAdminClient>();
|
||||
|
||||
// Docker container manager for per-tenant Clarity.Server instances
|
||||
builder.Services.AddSingleton<ClarityContainerService>();
|
||||
|
||||
// Tenant registry - persists provisioned tenant XML files to ClientAssets folder
|
||||
builder.Services.AddSingleton<TenantRegistryService>();
|
||||
|
||||
// Saga steps in execution order — container launches LAST once all context is populated
|
||||
builder.Services.AddSingleton<ISagaStep, KeycloakStep>();
|
||||
builder.Services.AddSingleton<ISagaStep, VaultStep>();
|
||||
builder.Services.AddSingleton<ISagaStep, MigrationStep>();
|
||||
builder.Services.AddSingleton<ISagaStep, LaunchStep>();
|
||||
builder.Services.AddSingleton<ISagaStep, HandoffStep>();
|
||||
|
||||
builder.Services.AddMassTransit(x =>
|
||||
{
|
||||
x.SetKebabCaseEndpointNameFormatter();
|
||||
|
||||
x.AddConsumer<ProvisioningConsumer>();
|
||||
|
||||
x.UsingRabbitMq((ctx, cfg) =>
|
||||
{
|
||||
cfg.Host(builder.Configuration.GetConnectionString("rabbitmq"));
|
||||
cfg.ConfigureEndpoints(ctx);
|
||||
});
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
var host = builder.Build();
|
||||
host.Run();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.Error.WriteLine($"FATAL WORKER CRASH: {ex}");
|
||||
throw;
|
||||
}
|
||||
Reference in New Issue
Block a user