36 lines
864 B
C#
36 lines
864 B
C#
using ContainerDashboard.Services;
|
|
using ContainerDashboard.Repositories;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
|
builder.Services.AddOpenApi();
|
|
builder.Services.AddTransient<IContainerService, ContainerService>();
|
|
builder.Services.AddControllers();
|
|
|
|
var backend = Environment.GetEnvironmentVariable("BACKEND");
|
|
|
|
switch (backend)
|
|
{
|
|
case "kubernetes":
|
|
builder.Services.AddTransient<IContainerHandler, KubernetesHandler>();
|
|
break;
|
|
case "docker":
|
|
throw new NotImplementedException();
|
|
default:
|
|
throw new Exception("Incorrect backend variable");
|
|
}
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.MapOpenApi();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
app.MapControllers();
|
|
|
|
app.Run();
|