config: update schema
All checks were successful
continuous-integration/drone/push Build is passing

* couple session-related attrs in a record
* couple logger-pertaining attrs in a record
* update config Go representation
* update Go config consumers
This commit is contained in:
leo 2023-05-05 19:31:43 +02:00
parent 5a1ec4fe28
commit bfafc4a8be
Signed by: wanderer
SSH Key Fingerprint: SHA256:Dp8+iwKHSlrMEHzE3bJnPng70I7LEsa3IJXRH/U+idQ
10 changed files with 50 additions and 31 deletions

View File

@ -17,12 +17,17 @@ import (
const connstr = "file:ent_tests?mode=memory&_fk=1"
var conf = &config.Config{
Port: 3005,
AppName: "pcmt-test",
LiveMode: true,
DevelMode: false,
SessionCookieName: "sessionz",
SessionCookieSecret: "secret",
Port: 3005,
AppName: "pcmt-test",
LiveMode: true,
DevelMode: false,
Session: struct {
CookieName string
CookieSecret string
}{
CookieName: "sessionz",
CookieSecret: "secret",
},
}
var (

View File

@ -38,8 +38,8 @@ func (s *Settings) Consolidate(conf *config.Config, host *string, port *int, dev
s.SetAppName(conf.AppName)
s.SetIsLive(conf.LiveMode)
s.SetIsDevel(conf.DevelMode)
s.SetSessionCookieName(conf.SessionCookieName)
s.SetSessionCookieSecret(conf.SessionCookieSecret)
s.SetSessionCookieName(conf.Session.CookieName)
s.SetSessionCookieSecret(conf.Session.CookieSecret)
log.Debug("checking flag overrides")

View File

@ -11,14 +11,23 @@ import (
"github.com/philandstuff/dhall-golang/v6"
)
type session struct {
CookieName string
CookieSecret string
}
type Config struct {
Host string
Port int
AppName string
LiveMode bool
DevelMode bool
SessionCookieName string
SessionCookieSecret string
Host string
Port int
AppName string
LiveMode bool
DevelMode bool
Session session
Registration struct{ Allowed bool }
Logger struct {
Json bool //nolint:revive
Fmt string
}
}
func LoadConfig(conf string, isPath bool) (*Config, error) {

View File

@ -39,7 +39,7 @@ func TestConfig(t *testing.T) {
conf: `
let ConfigSchema =
https://git.dotya.ml/mirre-mt/pcmt/raw/branch/development/config/schema/package.dhall
sha256:ad7ba86d5d388a99b7543faa0e4c81ba1d9b78fa6c32fdaf4ac4477089d177be
sha256:c82b0904c261d442e5765c2f47d76ad53c3c3ed16ace1b33416cedf98f2f5df0
? https://git.dotya.ml/mirre-mt/pcmt/raw/branch/development/config/schema/package.dhall
let Config = ConfigSchema.Schema
@ -57,7 +57,7 @@ func TestConfig(t *testing.T) {
conf: `
let ConfigSchema =
https://git.dotya.ml/mirre-mt/pcmt/raw/branch/development/config/schema/package.dhall
sha256:ad7ba86d5d388a99b7543faa0e4c81ba1d9b78fa6c32fdaf4ac4477089d177be
sha256:c82b0904c261d442e5765c2f47d76ad53c3c3ed16ace1b33416cedf98f2f5df0
? https://git.dotya.ml/mirre-mt/pcmt/raw/branch/development/config/schema/package.dhall
let Config = ConfigSchema.Schema

View File

@ -1,10 +1,10 @@
{ Schema =
./schema.dhall
sha256:1e8d4a3e16af1fa5b9b602a62c59440b933652c04b695095651ee04194b97138
sha256:3269ff2c6eba9856b819f3e7fccd44f2745fdff9d02498e6f0a1474ce650af17
? ./schema.dhall
, Schema/validate =
./validate.dhall
sha256:eb0df6eb95180f502ec1fbdf62ba6010e2cfc82b3dfe75163fa686d98c31eb6b
sha256:9e327f316fce0ced3598e14020a8a1ee3bd603a7817cb9e62ceddac3ece10e76
? ./validate.dhall
, Prelude =
./prelude.dhall

View File

@ -6,8 +6,9 @@ let Schema =
, AppName : Text
, LiveMode : Bool
, DevelMode : Bool
, SessionCookieName : Optional Text
, SessionCookieSecret : Optional Text
, Session : { CookieName : Optional Text, CookieSecret : Text }
, Logger : { Json : Bool, Fmt : Optional Text }
, Registration : { Allowed : Bool }
}
, default =
-- | have sane defaults.
@ -16,8 +17,9 @@ let Schema =
, AppName = "pcmt"
, LiveMode = False
, DevelMode = False
, SessionCookieName = None Text
, SessionCookieSecret = None Text
, Session = { CookieName = None Text, CookieSecret = "secretz" }
, Logger = { Json = True, Fmt = None Text }
, Registration.Allowed = True
}
}

View File

@ -5,7 +5,7 @@ let Prelude =
let Schema =
./schema.dhall
sha256:1e8d4a3e16af1fa5b9b602a62c59440b933652c04b695095651ee04194b97138
sha256:3269ff2c6eba9856b819f3e7fccd44f2745fdff9d02498e6f0a1474ce650af17
? ./schema.dhall
let Schema/validate

View File

@ -1,6 +1,7 @@
let ConfigSchema =
https://git.dotya.ml/mirre-mt/pcmt/raw/branch/development/config/schema/package.dhall
sha256:ad7ba86d5d388a99b7543faa0e4c81ba1d9b78fa6c32fdaf4ac4477089d177be
https://git.dotya.ml/mirre-mt/pcmt/raw/branch/development/config/schema/package.dhall
sha256:c82b0904c261d442e5765c2f47d76ad53c3c3ed16ace1b33416cedf98f2f5df0
? https://git.dotya.ml/mirre-mt/pcmt/raw/branch/development/config/schema/package.dhall
let Config = ConfigSchema.Schema

View File

@ -1,6 +1,7 @@
let ConfigSchema =
https://git.dotya.ml/mirre-mt/pcmt/raw/branch/development/config/schema/package.dhall
sha256:ad7ba86d5d388a99b7543faa0e4c81ba1d9b78fa6c32fdaf4ac4477089d177be
https://git.dotya.ml/mirre-mt/pcmt/raw/branch/development/config/schema/package.dhall
sha256:c82b0904c261d442e5765c2f47d76ad53c3c3ed16ace1b33416cedf98f2f5df0
? https://git.dotya.ml/mirre-mt/pcmt/raw/branch/development/config/schema/package.dhall
let Config = ConfigSchema.Schema

View File

@ -1,7 +1,8 @@
{- import config schema that is integrity-check protected -}
{- import config schema that is integrity-check protected (with a fallback) -}
let ConfigSchema =
https://git.dotya.ml/mirre-mt/pcmt/raw/branch/development/config/schema/package.dhall
sha256:ad7ba86d5d388a99b7543faa0e4c81ba1d9b78fa6c32fdaf4ac4477089d177be
https://git.dotya.ml/mirre-mt/pcmt/raw/branch/development/config/schema/package.dhall
sha256:c82b0904c261d442e5765c2f47d76ad53c3c3ed16ace1b33416cedf98f2f5df0
? https://git.dotya.ml/mirre-mt/pcmt/raw/branch/development/config/schema/package.dhall
let Config = ConfigSchema.Schema