using System; using System.IO; using Microsoft.Extensions.Options; using StellaOps.Scanner.Surface.Env; using StellaOps.Scanner.Surface.FS; namespace StellaOps.Scanner.WebService.Options; /// /// Aligns surface manifest store options with environment-derived cache settings. /// public sealed class SurfaceManifestStoreOptionsConfigurator : IConfigureOptions { private readonly ISurfaceEnvironment _surfaceEnvironment; private readonly IOptions _cacheOptions; public SurfaceManifestStoreOptionsConfigurator( ISurfaceEnvironment surfaceEnvironment, IOptions 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"); } } }