#559 +semver: breaking always use environment when working out AddOcelot on builder

This commit is contained in:
Tom Gardham-Pallister
2018-09-20 18:33:00 +01:00
parent 7c0aa6f97e
commit dcc3f0deae
3 changed files with 34 additions and 11 deletions

View File

@ -107,7 +107,7 @@ Instead of adding the configuration directly e.g. AddJsonFile("ocelot.json") you
.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath)
.AddJsonFile("appsettings.json", true, true)
.AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true, true)
.AddOcelot()
.AddOcelot(hostingContext.HostingEnvironment)
.AddEnvironmentVariables();
})
@ -117,6 +117,22 @@ The way Ocelot merges the files is basically load them, loop over them, add any
At the moment there is no validation at this stage it only happens when Ocelot validates the final merged configuration. This is something to be aware of when you are investigating problems. I would advise always checking what is in ocelot.json if you have any problems.
You can also give Ocelot a specific path to look in for the configuration files like below.
.. code-block:: csharp
.ConfigureAppConfiguration((hostingContext, config) =>
{
config
.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath)
.AddJsonFile("appsettings.json", true, true)
.AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true, true)
.AddOcelot("/foo/bar", hostingContext.HostingEnvironment)
.AddEnvironmentVariables();
})
Ocelot needs the HostingEnvironment so it know's to exclude anything environment specific from the algorithm.
Store configuration in consul
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^