From f8c6651c1b0e2613476b9530cda3e80fcfc9a390 Mon Sep 17 00:00:00 2001 From: Ryan Campbell Date: Fri, 2 Aug 2024 02:58:52 +0000 Subject: [PATCH 1/2] update-appsettings-load --- src/Program.cs | 15 +++++++++++---- test/debugClient/Program.cs | 14 +++++++++++--- test/integrationTests/TestSharedContext.cs | 14 +++++++++++++- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/Program.cs b/src/Program.cs index bd305e4..c76bbca 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -4,10 +4,17 @@ public class Program { public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); - builder.Configuration.AddJsonFile("/workspaces/hostsvc-position-config/appsettings.json", optional: true, reloadOnChange: true) - .AddJsonFile("/workspaces/hostsvc-position/src/appsettings.json", optional: true, reloadOnChange: true) - .AddJsonFile("/workspaces/hostsvc-position/src/appsettings.{env:DOTNET_ENVIRONMENT}.json", optional: true, reloadOnChange: true) - .Build(); + // Load the configuration being supplicated by the cluster first + builder.Configuration.AddJsonFile(Path.Combine("{env:SPACEFX_CONFIG_DIR}", "config", "appsettings.json"), optional: true, reloadOnChange: false); + + // Load any local appsettings incase they're overriding the cluster values + builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"), optional: true, reloadOnChange: false); + + // Load any local appsettings incase they're overriding the cluster values + builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.{env:DOTNET_ENVIRONMENT}.json"), optional: true, reloadOnChange: false); + + // Build the configuration + build.Configuration.Build(); builder.WebHost.ConfigureKestrel(options => options.ListenAnyIP(50051, o => o.Protocols = HttpProtocols.Http2)) .ConfigureServices((services) => { diff --git a/test/debugClient/Program.cs b/test/debugClient/Program.cs index adf4a7f..377c8be 100644 --- a/test/debugClient/Program.cs +++ b/test/debugClient/Program.cs @@ -4,9 +4,17 @@ public class Program { public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); - builder.Configuration - .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) - .AddJsonFile("appsettings.{env:DOTNET_ENVIRONMENT}.json", optional: true, reloadOnChange: true); + // Load the configuration being supplicated by the cluster first + builder.Configuration.AddJsonFile(Path.Combine("{env:SPACEFX_CONFIG_DIR}", "config", "appsettings.json"), optional: true, reloadOnChange: false); + + // Load any local appsettings incase they're overriding the cluster values + builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"), optional: true, reloadOnChange: false); + + // Load any local appsettings incase they're overriding the cluster values + builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.{env:DOTNET_ENVIRONMENT}.json"), optional: true, reloadOnChange: false); + + // Build the configuration + build.Configuration.Build(); builder.WebHost.ConfigureKestrel(options => options.ListenAnyIP(50051, o => o.Protocols = HttpProtocols.Http2)) .ConfigureServices((services) => { diff --git a/test/integrationTests/TestSharedContext.cs b/test/integrationTests/TestSharedContext.cs index fb07cf9..a19695b 100644 --- a/test/integrationTests/TestSharedContext.cs +++ b/test/integrationTests/TestSharedContext.cs @@ -24,7 +24,19 @@ public TestSharedContext() { if (_grpcHost != null) return; var builder = WebApplication.CreateBuilder(); - builder.Configuration.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); + + // Load the configuration being supplicated by the cluster first + builder.Configuration.AddJsonFile(Path.Combine("{env:SPACEFX_CONFIG_DIR}", "config", "appsettings.json"), optional: true, reloadOnChange: false); + + // Load any local appsettings incase they're overriding the cluster values + builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"), optional: true, reloadOnChange: false); + + // Load any local appsettings incase they're overriding the cluster values + builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.{env:DOTNET_ENVIRONMENT}.json"), optional: true, reloadOnChange: false); + + // Build the configuration + build.Configuration.Build(); + builder.WebHost.ConfigureKestrel(options => options.ListenAnyIP(50051, o => o.Protocols = HttpProtocols.Http2)) .ConfigureServices((services) => { From 822ea2a732cac6a1bdfa9076bff203f79ccb6773 Mon Sep 17 00:00:00 2001 From: Ryan Campbell Date: Fri, 2 Aug 2024 03:07:45 +0000 Subject: [PATCH 2/2] copy and paste dust bunny --- src/Program.cs | 3 --- test/debugClient/Program.cs | 3 --- test/integrationTests/TestSharedContext.cs | 3 --- 3 files changed, 9 deletions(-) diff --git a/src/Program.cs b/src/Program.cs index c76bbca..f5c495e 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -13,9 +13,6 @@ public static void Main(string[] args) { // Load any local appsettings incase they're overriding the cluster values builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.{env:DOTNET_ENVIRONMENT}.json"), optional: true, reloadOnChange: false); - // Build the configuration - build.Configuration.Build(); - builder.WebHost.ConfigureKestrel(options => options.ListenAnyIP(50051, o => o.Protocols = HttpProtocols.Http2)) .ConfigureServices((services) => { services.AddAzureOrbitalFramework(); diff --git a/test/debugClient/Program.cs b/test/debugClient/Program.cs index 377c8be..f29b053 100644 --- a/test/debugClient/Program.cs +++ b/test/debugClient/Program.cs @@ -13,9 +13,6 @@ public static void Main(string[] args) { // Load any local appsettings incase they're overriding the cluster values builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.{env:DOTNET_ENVIRONMENT}.json"), optional: true, reloadOnChange: false); - // Build the configuration - build.Configuration.Build(); - builder.WebHost.ConfigureKestrel(options => options.ListenAnyIP(50051, o => o.Protocols = HttpProtocols.Http2)) .ConfigureServices((services) => { services.AddAzureOrbitalFramework(); diff --git a/test/integrationTests/TestSharedContext.cs b/test/integrationTests/TestSharedContext.cs index a19695b..d4db866 100644 --- a/test/integrationTests/TestSharedContext.cs +++ b/test/integrationTests/TestSharedContext.cs @@ -34,9 +34,6 @@ public TestSharedContext() { // Load any local appsettings incase they're overriding the cluster values builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.{env:DOTNET_ENVIRONMENT}.json"), optional: true, reloadOnChange: false); - // Build the configuration - build.Configuration.Build(); - builder.WebHost.ConfigureKestrel(options => options.ListenAnyIP(50051, o => o.Protocols = HttpProtocols.Http2)) .ConfigureServices((services) => {