using Recyclarr.Common.Extensions; using Recyclarr.TrashLib.Startup; using YamlDotNet.Serialization; namespace Recyclarr.TrashLib.Config.Secrets; public class SecretsProvider : ISecretsProvider { public IReadOnlyDictionary Secrets => _secrets.Value; private readonly IAppPaths _paths; private readonly Lazy> _secrets; public SecretsProvider(IAppPaths paths) { _paths = paths; _secrets = new Lazy>(LoadSecretsFile); } private Dictionary LoadSecretsFile() { var yamlPath = _paths.AppDataDirectory.YamlFile("secrets"); if (yamlPath is null) { return new Dictionary(); } using var stream = yamlPath.OpenText(); var deserializer = new DeserializerBuilder().Build(); var result = deserializer.Deserialize?>(stream); return result ?? new Dictionary(); } }