[go: nahoru, domu]

Skip to content
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

Finishing off PR for supporting user secrets [#115] #123

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add user secrets #115
  • Loading branch information
kgday authored and Ben Collins committed Jul 3, 2024
commit 187ec28680c227415def57547b05983016931f98
15 changes: 13 additions & 2 deletions src/Falco/ConfigBuilder.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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[]) =
Expand Down Expand Up @@ -51,6 +54,9 @@ type ConfigBuilder (args : string[]) =

bldr.AddCommandLine(args) |> ignore

if conf.AddUserSecrets then
bldr.AddUserSecrets() |> ignore

bldr.Build() :> IConfiguration

/// Sets the base path of the ConfigurationBuilder.
Expand Down Expand Up @@ -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")>]
member _.AddOptionalUserSecrets (conf : ConfigBuilderSpec) =
{ conf with AddUserSecrets = true }

[<AutoOpen>]
module ConfigurationBuilder =
/// Computation expression to allow for elegant IConfiguration construction.
Expand Down