Files
git.stella-ops.org/src/__Libraries/StellaOps.AuditPack/Services/AuditBundleReader.Manifest.cs

28 lines
936 B
C#

using System.Text.Json;
using StellaOps.AuditPack.Models;
namespace StellaOps.AuditPack.Services;
public sealed partial class AuditBundleReader
{
private static async Task<ManifestLoadResult> LoadManifestAsync(
string bundleDir,
CancellationToken ct)
{
var manifestPath = Path.Combine(bundleDir, "manifest.json");
if (!File.Exists(manifestPath))
{
return new ManifestLoadResult(false, "Manifest not found in bundle", null, null);
}
var manifestBytes = await File.ReadAllBytesAsync(manifestPath, ct).ConfigureAwait(false);
var manifest = JsonSerializer.Deserialize<AuditBundleManifest>(manifestBytes, _jsonOptions);
if (manifest is null)
{
return new ManifestLoadResult(false, "Failed to parse manifest", null, manifestBytes);
}
return new ManifestLoadResult(true, null, manifest, manifestBytes);
}
}