feat(concelier): accept environment name or GUID in readiness endpoint
The /environments/{id}/readiness endpoint now resolves environment names
(e.g. "dev", "prod-us-east") via IEnvironmentService, returning an empty
list for unregistered environments instead of a 404.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ using StellaOps.ReleaseOrchestrator.Environment.InfrastructureBinding;
|
||||
using StellaOps.ReleaseOrchestrator.Environment.Readiness;
|
||||
using StellaOps.ReleaseOrchestrator.Environment.Region;
|
||||
using StellaOps.ReleaseOrchestrator.Environment.Rename;
|
||||
using StellaOps.ReleaseOrchestrator.Environment.Services;
|
||||
using EnvModels = StellaOps.ReleaseOrchestrator.Environment.Models;
|
||||
|
||||
namespace StellaOps.Concelier.WebService.Extensions;
|
||||
@@ -365,12 +366,37 @@ internal static class TopologySetupEndpointExtensions
|
||||
var envs = app.MapGroup("/api/v1/environments")
|
||||
.WithTags("Topology Readiness");
|
||||
|
||||
envs.MapGet("/{id:guid}/readiness", async (
|
||||
Guid id,
|
||||
// Accept GUID or environment name (e.g. "dev", "stage", "prod-us-east").
|
||||
// Returns an empty list when the environment has no targets registered yet.
|
||||
envs.MapGet("/{id}/readiness", async (
|
||||
string id,
|
||||
[FromServices] ITopologyReadinessService readinessService,
|
||||
[FromServices] IEnvironmentService environmentService,
|
||||
CancellationToken ct) =>
|
||||
{
|
||||
var reports = await readinessService.ListByEnvironmentAsync(id, ct);
|
||||
Guid? environmentId = null;
|
||||
if (Guid.TryParse(id, out var parsed))
|
||||
{
|
||||
environmentId = parsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
var env = await environmentService.GetByNameAsync(id, ct);
|
||||
if (env is not null)
|
||||
environmentId = env.Id;
|
||||
}
|
||||
|
||||
// Environment not yet registered in orchestrator → empty readiness (not an error)
|
||||
if (environmentId is null)
|
||||
{
|
||||
return HttpResults.Ok(new ReadinessListResponse
|
||||
{
|
||||
Items = [],
|
||||
TotalCount = 0
|
||||
});
|
||||
}
|
||||
|
||||
var reports = await readinessService.ListByEnvironmentAsync(environmentId.Value, ct);
|
||||
return HttpResults.Ok(new ReadinessListResponse
|
||||
{
|
||||
Items = reports.Select(MapReport).ToList(),
|
||||
|
||||
Reference in New Issue
Block a user