-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathChickenCheckConfiguration.fs
55 lines (45 loc) · 1.37 KB
/
ChickenCheckConfiguration.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
module ChickenCheckConfiguration
open FsConfig
open Microsoft.Extensions.Configuration
open System.IO
type Authentication =
{ Domain: string
ClientId: string
ClientSecret: string }
type Database =
{ User: string
Password: string }
type Local = { Db: Database }
type Backup =
{ AzureStorageConnectionString: string}
type Config =
{ DataProtectionCertificatePassword: string
Local: Local
Dev: Authentication
DevDb: Database
Prod: Authentication
ProdDb: Database
Backup: Backup }
let configRoot =
ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddUserSecrets("de84dfcb-ba79-4405-8811-8124e96a1b3b")
.Build()
let [<Literal>] ConfigErrorMsg =
"""
************************************************************
* Failed to read configuration variables.
* For local development you need to add local user-secrets,
************************************************************
"""
let config =
lazy
let appConfig = AppConfig(configRoot)
match appConfig.Get<Config>() with
| Ok config ->
config
| Error msg ->
match msg with
| BadValue (name, msg) -> invalidArg name msg
| NotFound name -> invalidArg name "Not found"
| NotSupported name -> invalidArg name "Could not read config value"