OPC # 0006: OPC Git Trunk-Based management
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -2,6 +2,7 @@ using System.Diagnostics;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using ControlPlane.Api.Services;
|
||||
using ControlPlane.Core.Services;
|
||||
|
||||
namespace ControlPlane.Api.Endpoints;
|
||||
|
||||
@@ -14,6 +15,7 @@ public static class ImageBuildEndpoints
|
||||
var group = app.MapGroup("/api/image").WithTags("Image");
|
||||
|
||||
group.MapGet("/status", GetStatus);
|
||||
group.MapGet("/history", GetHistory);
|
||||
group.MapPost("/build", TriggerBuild);
|
||||
|
||||
// Post-provisioning verification helpers
|
||||
@@ -28,6 +30,26 @@ public static class ImageBuildEndpoints
|
||||
private static async Task<IResult> GetStatus(ImageBuildService svc) =>
|
||||
Results.Ok(await svc.GetStatusAsync());
|
||||
|
||||
/// <summary>Returns recent DockerImage build records for the sparkline chart.</summary>
|
||||
private static async Task<IResult> GetHistory(BuildHistoryService history, int limit = 30)
|
||||
{
|
||||
var all = await history.GetBuildsAsync();
|
||||
var records = all
|
||||
.Where(b => b.Kind == ControlPlane.Core.Models.BuildKind.DockerImage)
|
||||
.Take(Math.Clamp(limit, 1, 100))
|
||||
.Select(b => new
|
||||
{
|
||||
b.Id,
|
||||
b.Status,
|
||||
b.StartedAt,
|
||||
b.DurationMs,
|
||||
b.CommitSha,
|
||||
b.ImageDigest,
|
||||
})
|
||||
.ToList();
|
||||
return Results.Ok(records);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triggers a docker build and streams the output line-by-line as SSE.
|
||||
/// The build context is the repo root, which must be configured via
|
||||
|
||||
Reference in New Issue
Block a user