in src/Infrastructure/Providers/Concrete/FileSecretProvider.cs [40:65]
public IReadOnlyDictionary<string, string> GetSecretNameToValueMap()
{
var map = new Dictionary<string, string>();
Console.WriteLine($"Fetching secrets from folder {_secretsFolderPath}.");
if (!Directory.Exists(_secretsFolderPath))
{
throw new DirectoryNotFoundException($"Secrets directory {_secretsFolderPath} is missing.");
}
var files = Directory.GetFiles(_secretsFolderPath, "*", SearchOption.TopDirectoryOnly);
foreach (var file in files)
{
var secretName = Path.GetFileName(file);
var secretValue = GetSecret(file);
map.Add(secretName, secretValue);
}
var missingSecrets = _secrets.Except(map.Keys).ToList();
if (missingSecrets.Any())
{
throw new Exception($"Not all mapped secrets could be found [missing: {string.Join(",", missingSecrets)}].");
}
return new ReadOnlyDictionary<string, string>(map);
}