fix tests. new product advisories enhancements
This commit is contained in:
@@ -88,6 +88,31 @@ public sealed class DoctorEngine
|
||||
return report;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs checks and returns simplified results for dashboard consumption.
|
||||
/// </summary>
|
||||
public async Task<IReadOnlyList<CheckResult>> RunChecksAsync(
|
||||
DoctorRunOptions options,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
var report = await RunAsync(options, progress: null, ct);
|
||||
return report.Results.Select(r => new CheckResult
|
||||
{
|
||||
CheckId = r.CheckId,
|
||||
Severity = MapSeverity(r.Severity),
|
||||
IsHealthy = r.Severity.IsSuccess(),
|
||||
Message = r.Diagnosis,
|
||||
Metadata = r.Evidence.Data ?? ImmutableDictionary<string, string>.Empty
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
private static CheckSeverity MapSeverity(DoctorSeverity severity) => severity switch
|
||||
{
|
||||
DoctorSeverity.Fail => CheckSeverity.Critical,
|
||||
DoctorSeverity.Warn => CheckSeverity.Warning,
|
||||
_ => CheckSeverity.Info
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Lists all available checks.
|
||||
/// </summary>
|
||||
|
||||
44
src/__Libraries/StellaOps.Doctor/Models/CheckResult.cs
Normal file
44
src/__Libraries/StellaOps.Doctor/Models/CheckResult.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
// <copyright file="CheckResult.cs" company="Stella Operations">
|
||||
// Copyright (c) Stella Operations. Licensed under BUSL-1.1.
|
||||
// </copyright>
|
||||
|
||||
using System.Collections.Immutable;
|
||||
|
||||
namespace StellaOps.Doctor.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Severity levels for simplified dashboard health checks.
|
||||
/// Maps from <see cref="DoctorSeverity"/> for dashboard consumption.
|
||||
/// </summary>
|
||||
public enum CheckSeverity
|
||||
{
|
||||
/// <summary>Informational - no action required.</summary>
|
||||
Info,
|
||||
/// <summary>Warning - should be addressed soon.</summary>
|
||||
Warning,
|
||||
/// <summary>Critical - immediate action required.</summary>
|
||||
Critical
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Simplified check result for dashboard providers.
|
||||
/// Produced by <see cref="Engine.DoctorEngine.RunChecksAsync"/> for quick status reads.
|
||||
/// </summary>
|
||||
public sealed record CheckResult
|
||||
{
|
||||
/// <summary>Gets the unique check identifier.</summary>
|
||||
public required string CheckId { get; init; }
|
||||
|
||||
/// <summary>Gets the check severity level.</summary>
|
||||
public required CheckSeverity Severity { get; init; }
|
||||
|
||||
/// <summary>Gets whether the check passed.</summary>
|
||||
public required bool IsHealthy { get; init; }
|
||||
|
||||
/// <summary>Gets the result message.</summary>
|
||||
public required string Message { get; init; }
|
||||
|
||||
/// <summary>Gets additional metadata key-value pairs.</summary>
|
||||
public IReadOnlyDictionary<string, string> Metadata { get; init; } =
|
||||
ImmutableDictionary<string, string>.Empty;
|
||||
}
|
||||
@@ -75,6 +75,11 @@ public sealed record DoctorRunOptions
|
||||
/// </summary>
|
||||
public string? TenantId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether to stop running on first check failure.
|
||||
/// </summary>
|
||||
public bool FailFast { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Command used to invoke the run (for evidence logs).
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user