mirror of
https://github.com/Smaug123/PulumiConfig
synced 2025-10-27 18:18:56 +00:00
Add radicale and gitea config to schema (#41)
This commit is contained in:
@@ -70,6 +70,8 @@ module TestConfiguration =
|
|||||||
Subdomains = Set.empty
|
Subdomains = Set.empty
|
||||||
AcmeEmail = EmailAddress "test@example.com"
|
AcmeEmail = EmailAddress "test@example.com"
|
||||||
RemoteUsername = Username "non-root"
|
RemoteUsername = Username "non-root"
|
||||||
|
RadicaleConfig = None
|
||||||
|
GiteaConfig = None
|
||||||
}
|
}
|
||||||
|
|
||||||
let serialised = SerialisedConfig.Make publicConfig
|
let serialised = SerialisedConfig.Make publicConfig
|
||||||
|
|||||||
@@ -5,6 +5,23 @@ open System.Collections.Generic
|
|||||||
open System.IO
|
open System.IO
|
||||||
open Newtonsoft.Json
|
open Newtonsoft.Json
|
||||||
|
|
||||||
|
[<NoComparison>]
|
||||||
|
type RadicaleConfig =
|
||||||
|
{
|
||||||
|
User : string
|
||||||
|
Password : string
|
||||||
|
GitEmail : string
|
||||||
|
}
|
||||||
|
|
||||||
|
[<NoComparison>]
|
||||||
|
type GiteaConfig =
|
||||||
|
{
|
||||||
|
ServerPassword : string
|
||||||
|
AdminPassword : string
|
||||||
|
AdminEmailAddress : string
|
||||||
|
AdminUsername : string
|
||||||
|
}
|
||||||
|
|
||||||
[<NoComparison>]
|
[<NoComparison>]
|
||||||
type Configuration =
|
type Configuration =
|
||||||
{
|
{
|
||||||
@@ -30,6 +47,8 @@ type Configuration =
|
|||||||
AcmeEmail : EmailAddress
|
AcmeEmail : EmailAddress
|
||||||
/// Username for the user account to be created on the server
|
/// Username for the user account to be created on the server
|
||||||
RemoteUsername : Username
|
RemoteUsername : Username
|
||||||
|
RadicaleConfig : RadicaleConfig option
|
||||||
|
GiteaConfig : GiteaConfig option
|
||||||
}
|
}
|
||||||
|
|
||||||
member this.PublicKey =
|
member this.PublicKey =
|
||||||
@@ -39,6 +58,61 @@ type Configuration =
|
|||||||
let (PrivateKey k) = this.PrivateKey
|
let (PrivateKey k) = this.PrivateKey
|
||||||
Path.Combine (k.Directory.FullName, k.Name + ".pub") |> FileInfo |> PublicKey
|
Path.Combine (k.Directory.FullName, k.Name + ".pub") |> FileInfo |> PublicKey
|
||||||
|
|
||||||
|
[<NoComparison>]
|
||||||
|
type SerialisedRadicaleConfig =
|
||||||
|
{
|
||||||
|
[<JsonProperty(Required = Required.Always)>]
|
||||||
|
User : string
|
||||||
|
[<JsonProperty(Required = Required.Always)>]
|
||||||
|
Password : string
|
||||||
|
[<JsonProperty(Required = Required.Always)>]
|
||||||
|
GitEmail : string
|
||||||
|
}
|
||||||
|
|
||||||
|
static member Make (config : RadicaleConfig) : SerialisedRadicaleConfig =
|
||||||
|
{
|
||||||
|
User = config.User
|
||||||
|
Password = config.Password
|
||||||
|
GitEmail = config.GitEmail
|
||||||
|
}
|
||||||
|
|
||||||
|
static member Deserialise (config : SerialisedRadicaleConfig) : RadicaleConfig =
|
||||||
|
{
|
||||||
|
User = config.User
|
||||||
|
Password = config.Password
|
||||||
|
GitEmail = config.GitEmail
|
||||||
|
}
|
||||||
|
|
||||||
|
[<NoComparison>]
|
||||||
|
type SerialisedGiteaConfig =
|
||||||
|
{
|
||||||
|
[<JsonProperty(Required = Required.Always)>]
|
||||||
|
ServerPassword : string
|
||||||
|
[<JsonProperty(Required = Required.Always)>]
|
||||||
|
AdminPassword : string
|
||||||
|
[<JsonProperty(Required = Required.Always)>]
|
||||||
|
AdminEmailAddress : string
|
||||||
|
[<JsonProperty(Required = Required.Always)>]
|
||||||
|
AdminUsername : string
|
||||||
|
}
|
||||||
|
|
||||||
|
static member Make (config : GiteaConfig) : SerialisedGiteaConfig =
|
||||||
|
{
|
||||||
|
ServerPassword = config.ServerPassword
|
||||||
|
AdminPassword = config.AdminPassword
|
||||||
|
AdminEmailAddress = config.AdminEmailAddress
|
||||||
|
AdminUsername = config.AdminUsername
|
||||||
|
}
|
||||||
|
|
||||||
|
static member Deserialise (config : SerialisedGiteaConfig) : GiteaConfig =
|
||||||
|
{
|
||||||
|
ServerPassword = config.ServerPassword
|
||||||
|
AdminPassword = config.AdminPassword
|
||||||
|
AdminEmailAddress = config.AdminEmailAddress
|
||||||
|
AdminUsername = config.AdminUsername
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[<NoComparison>]
|
[<NoComparison>]
|
||||||
[<RequireQualifiedAccess>]
|
[<RequireQualifiedAccess>]
|
||||||
type SerialisedConfig =
|
type SerialisedConfig =
|
||||||
@@ -61,6 +135,10 @@ type SerialisedConfig =
|
|||||||
AcmeEmail : string
|
AcmeEmail : string
|
||||||
[<JsonProperty(Required = Required.Always)>]
|
[<JsonProperty(Required = Required.Always)>]
|
||||||
RemoteUsername : string
|
RemoteUsername : string
|
||||||
|
[<JsonProperty(Required = Required.Default)>]
|
||||||
|
RadicaleConfig : SerialisedRadicaleConfig
|
||||||
|
[<JsonProperty(Required = Required.Default)>]
|
||||||
|
GiteaConfig : SerialisedGiteaConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
static member Make (config : Configuration) =
|
static member Make (config : Configuration) =
|
||||||
@@ -82,6 +160,11 @@ type SerialisedConfig =
|
|||||||
Subdomains = config.Subdomains |> Seq.map (fun sub -> sub.ToString ()) |> Seq.toArray
|
Subdomains = config.Subdomains |> Seq.map (fun sub -> sub.ToString ()) |> Seq.toArray
|
||||||
AcmeEmail = config.AcmeEmail.ToString ()
|
AcmeEmail = config.AcmeEmail.ToString ()
|
||||||
RemoteUsername = config.RemoteUsername.ToString ()
|
RemoteUsername = config.RemoteUsername.ToString ()
|
||||||
|
RadicaleConfig =
|
||||||
|
config.RadicaleConfig
|
||||||
|
|> Option.map SerialisedRadicaleConfig.Make
|
||||||
|
|> Option.toObj
|
||||||
|
GiteaConfig = config.GiteaConfig |> Option.map SerialisedGiteaConfig.Make |> Option.toObj
|
||||||
}
|
}
|
||||||
|
|
||||||
static member Deserialise (config : SerialisedConfig) : Configuration =
|
static member Deserialise (config : SerialisedConfig) : Configuration =
|
||||||
@@ -105,6 +188,14 @@ type SerialisedConfig =
|
|||||||
| subdomains -> subdomains |> Seq.map WellKnownSubdomain.Parse |> Set.ofSeq
|
| subdomains -> subdomains |> Seq.map WellKnownSubdomain.Parse |> Set.ofSeq
|
||||||
AcmeEmail = config.AcmeEmail |> EmailAddress
|
AcmeEmail = config.AcmeEmail |> EmailAddress
|
||||||
RemoteUsername = config.RemoteUsername |> Username
|
RemoteUsername = config.RemoteUsername |> Username
|
||||||
|
RadicaleConfig =
|
||||||
|
config.RadicaleConfig
|
||||||
|
|> Option.ofObj
|
||||||
|
|> Option.map SerialisedRadicaleConfig.Deserialise
|
||||||
|
GiteaConfig =
|
||||||
|
config.GiteaConfig
|
||||||
|
|> Option.ofObj
|
||||||
|
|> Option.map SerialisedGiteaConfig.Deserialise
|
||||||
}
|
}
|
||||||
|
|
||||||
[<RequireQualifiedAccess>]
|
[<RequireQualifiedAccess>]
|
||||||
|
|||||||
@@ -41,6 +41,72 @@
|
|||||||
},
|
},
|
||||||
"remoteUsername": {
|
"remoteUsername": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"radicaleConfig": {
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/SerialisedRadicaleConfig"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"giteaConfig": {
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"type": "null"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/SerialisedGiteaConfig"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"definitions": {
|
||||||
|
"SerialisedRadicaleConfig": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": [
|
||||||
|
"user",
|
||||||
|
"password",
|
||||||
|
"gitEmail"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"user": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"password": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"gitEmail": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"SerialisedGiteaConfig": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": [
|
||||||
|
"serverPassword",
|
||||||
|
"adminPassword",
|
||||||
|
"adminEmailAddress",
|
||||||
|
"adminUsername"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"serverPassword": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"adminPassword": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"adminEmailAddress": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"adminUsername": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user