Files
git.stella-ops.org/src/Scanner/StellaOps.Scanner.WebService/Options/SurfaceManifestStoreOptionsConfigurator.cs
StellaOps Bot 029002ad05 work
2025-11-23 23:40:10 +02:00

40 lines
1.5 KiB
C#

using System;
using System.IO;
using Microsoft.Extensions.Options;
using StellaOps.Scanner.Surface.Env;
using StellaOps.Scanner.Surface.FS;
namespace StellaOps.Scanner.WebService.Options;
/// <summary>
/// Aligns surface manifest store options with environment-derived cache settings.
/// </summary>
public sealed class SurfaceManifestStoreOptionsConfigurator : IConfigureOptions<SurfaceManifestStoreOptions>
{
private readonly ISurfaceEnvironment _surfaceEnvironment;
private readonly IOptions<SurfaceCacheOptions> _cacheOptions;
public SurfaceManifestStoreOptionsConfigurator(
ISurfaceEnvironment surfaceEnvironment,
IOptions<SurfaceCacheOptions> cacheOptions)
{
_surfaceEnvironment = surfaceEnvironment ?? throw new ArgumentNullException(nameof(surfaceEnvironment));
_cacheOptions = cacheOptions ?? throw new ArgumentNullException(nameof(cacheOptions));
}
public void Configure(SurfaceManifestStoreOptions options)
{
ArgumentNullException.ThrowIfNull(options);
var settings = _surfaceEnvironment.Settings;
options.Bucket = settings.SurfaceFsBucket;
options.Scheme = settings.SurfaceFsEndpoint.Scheme;
if (string.IsNullOrWhiteSpace(options.RootDirectory))
{
var cacheRoot = _cacheOptions.Value.RootDirectory ?? Path.Combine(Path.GetTempPath(), "stellaops", "surface-cache");
options.RootDirectory = Path.Combine(cacheRoot, "manifests");
}
}
}