This commit is contained in:
Zeeshaun
2026-04-21 11:35:51 -05:00
parent 8b3ea92501
commit 5bea84f4a9
6 changed files with 20 additions and 44 deletions
@@ -1,5 +1,3 @@
using System.Collections.Generic;
using System.IO;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
@@ -23,9 +21,10 @@ namespace LCU.Webapps.Marketing.SPIT
builder.AddJsonFile("/app/config/workload-appsettings/appsettings.json", optional: true, reloadOnChange: true);
builder.AddJsonFile("/vault/secrets/spit-seq-api-key.json", optional: true, reloadOnChange: true);
builder.AddJsonFile("/vault/secrets/spit-primary-subscription-key.json", optional: true, reloadOnChange: true);
builder.AddJsonFile("/vault/secrets/spit-speech-api-key.json", optional: true, reloadOnChange: true);
builder.AddJsonFile("/vault/secrets/spit-speech-endpoint.json", optional: true, reloadOnChange: true);
builder.AddJsonFile("/vault/secrets/spit-azuread-client-id.json", optional: true, reloadOnChange: true);
builder.AddJsonFile("/vault/secrets/spit-azuread-client-secret.json", optional: true, reloadOnChange: true);
builder.AddInMemoryCollection(LoadPlainTextSpeechSecrets());
})
.ConfigureWebHostDefaults(webBuilder =>
{
@@ -33,37 +32,5 @@ namespace LCU.Webapps.Marketing.SPIT
.UseSetting(WebHostDefaults.DetailedErrorsKey, "true")
.UseSerilog();
});
private static IDictionary<string, string> LoadPlainTextSpeechSecrets()
{
var configValues = new Dictionary<string, string>();
var secretMappings = new[]
{
(Path: "/vault/secrets/speech-api-key", Key: "Primary:SpeechApiKey"),
(Path: "/vault/secrets/speech-endpoint", Key: "Primary:SpeechEndpoint"),
};
foreach (var secretMapping in secretMappings)
{
TryAddSecretValue(configValues, secretMapping.Path, secretMapping.Key);
}
return configValues;
}
private static void TryAddSecretValue(IDictionary<string, string> configValues, string path, string key)
{
if (!File.Exists(path))
{
return;
}
var value = File.ReadAllText(path)?.Trim();
if (!string.IsNullOrWhiteSpace(value))
{
configValues[key] = value;
}
}
}
}