Improve config system

Add pkl to generate configs
This commit is contained in:
Tobias Reisinger 2024-02-18 19:50:22 +01:00
parent 8785186dfa
commit b2ff632e64
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
47 changed files with 916 additions and 277 deletions

15
config/lib/common.pkl Normal file
View file

@ -0,0 +1,15 @@
class ServerConfig {
host: String
port: UInt16
}
/// Set to a user and a group to drop privileges to after binding to the port
class PermissionsConfig {
user: String
group: String
}
class LoggingConfig {
level: String
file: String
}

16
config/lib/controller.pkl Normal file
View file

@ -0,0 +1,16 @@
import "./common.pkl"
server: common.ServerConfig
database: String
permissions: common.PermissionsConfig
logging: common.LoggingConfig
class RelayConfig {
driver: "gpio" | "piface"
pin: Number
inverted: Boolean
}
relays: Listing<RelayConfig>

12
config/lib/core.pkl Normal file
View file

@ -0,0 +1,12 @@
import "./common.pkl"
server: common.ServerConfig
database: String
permissions: common.PermissionsConfig
logging: common.LoggingConfig
/// Leave empty to allow all origins (will always respond with Origin and not "*")
origins: Listing<String>