-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add user secrets #115 #116
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,19 +8,22 @@ type ConfigFile = | |
| XmlFile of path : string | ||
| JsonFile of path : string | ||
|
||
|
||
type ConfigBuilderSpec = | ||
{ AddEnvVars : bool | ||
BasePath : string | ||
RequiredFiles : ConfigFile list | ||
OptionalFiles : ConfigFile list | ||
InMemory : Map<string, string> } | ||
InMemory : Map<string, string> | ||
AddUserSecrets: bool} | ||
|
||
static member Empty = | ||
{ AddEnvVars = false | ||
BasePath = Directory.GetCurrentDirectory() | ||
RequiredFiles = [] | ||
OptionalFiles = [] | ||
InMemory = Map.empty } | ||
InMemory = Map.empty | ||
AddUserSecrets= false } | ||
|
||
/// Computation expression to allow for elegant IConfiguration construction. | ||
type ConfigBuilder (args : string[]) = | ||
|
@@ -51,6 +54,9 @@ type ConfigBuilder (args : string[]) = | |
|
||
bldr.AddCommandLine(args) |> ignore | ||
|
||
if conf.AddUserSecrets then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should appear before env vars, I try to match the prior specified here: https://learn.microsoft.com/en-us/dotnet/core/extensions/configuration. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Goido. I'll fix that. |
||
bldr.AddUserSecrets() |> ignore | ||
|
||
bldr.Build() :> IConfiguration | ||
|
||
/// Sets the base path of the ConfigurationBuilder. | ||
|
@@ -101,6 +107,11 @@ type ConfigBuilder (args : string[]) = | |
member _.AddOptionalJsonFile (conf : ConfigBuilderSpec, filePath : string) = | ||
{ conf with OptionalFiles = (JsonFile filePath) :: conf.OptionalFiles } | ||
|
||
///Adds optional user secrets to the ConfigurationBuilder. | ||
[<CustomOperation("optional_user_secrets")>] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the non-optional brother of this omitted on purpose? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes because it is generally only used in the Development environment. In the default web builder of the c# template where it sets up all the config for you it only adds optional user secrets if the env is development. |
||
member _.AddOptionalUserSecrets (conf : ConfigBuilderSpec) = | ||
{ conf with AddUserSecrets = true } | ||
|
||
[<AutoOpen>] | ||
module ConfigurationBuilder = | ||
/// Computation expression to allow for elegant IConfiguration construction. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a space here to separate the type from the bracket.