dhall: switch to using the versioned config
All checks were successful
continuous-integration/drone/push Build is passing

the Dhall config package formerly in ./config/schema has been moved to
https://git.dotya.ml/mirre-mt/pcmt-config-schema/, meaning the schema
has been decoupled from this repository.

the schema is now being versioned, which makes it easier to progress
without breaking stuff (unless we wanted to reference the versions by
commit hashes...).

* use schema version 0.0.0
This commit is contained in:
leo 2023-05-06 01:48:03 +02:00
parent c4f8cf87f5
commit f8df3f3806
Signed by: wanderer
SSH Key Fingerprint: SHA256:Dp8+iwKHSlrMEHzE3bJnPng70I7LEsa3IJXRH/U+idQ
8 changed files with 14 additions and 85 deletions

@ -38,9 +38,9 @@ func TestConfig(t *testing.T) {
isPath: false,
conf: `
let ConfigSchema =
https://git.dotya.ml/mirre-mt/pcmt/raw/branch/development/config/schema/package.dhall
https://git.dotya.ml/mirre-mt/pcmt-config-schema/raw/tag/0.0.0/package.dhall
sha256:c82b0904c261d442e5765c2f47d76ad53c3c3ed16ace1b33416cedf98f2f5df0
? https://git.dotya.ml/mirre-mt/pcmt/raw/branch/development/config/schema/package.dhall
? https://git.dotya.ml/mirre-mt/pcmt-config-schema/raw/tag/0.0.0/package.dhall
let Config = ConfigSchema.Schema
@ -56,9 +56,9 @@ func TestConfig(t *testing.T) {
isPath: false,
conf: `
let ConfigSchema =
https://git.dotya.ml/mirre-mt/pcmt/raw/branch/development/config/schema/package.dhall
https://git.dotya.ml/mirre-mt/pcmt-config-schema/raw/tag/0.0.0/package.dhall
sha256:c82b0904c261d442e5765c2f47d76ad53c3c3ed16ace1b33416cedf98f2f5df0
? https://git.dotya.ml/mirre-mt/pcmt/raw/branch/development/config/schema/package.dhall
? https://git.dotya.ml/mirre-mt/pcmt-config-schema/raw/tag/0.0.0/package.dhall
let Config = ConfigSchema.Schema
@ -71,7 +71,8 @@ func TestConfig(t *testing.T) {
isPath: false,
conf: `
let ConfigSchema =
https://git.dotya.ml/mirre-mt/pcmt/raw/branch/development/config/schema/package.dhall
https://git.dotya.ml/mirre-mt/pcmt-config-schema/raw/tag/0.0.0/package.dhall
sha256:c82b0904c261d442e5765c2f47d76ad53c3c3ed16ace1b33416cedf98f2f5df0
in ConfigSchema.Schema::{ DevelMode = True, Port = 5555 }
`,
},
@ -81,7 +82,8 @@ func TestConfig(t *testing.T) {
isPath: false,
conf: `
let ConfigSchema =
https://git.dotya.ml/mirre-mt/pcmt/raw/branch/development/config/schema/package.dhall
https://git.dotya.ml/mirre-mt/pcmt-config-schema/raw/tag/0.0.0/package.dhall
sha256:c82b0904c261d442e5765c2f47d76ad53c3c3ed16ace1b33416cedf98f2f5df0
in ConfigSchema.Schema.default // { DevelMode = True }
`,
},

@ -1,12 +0,0 @@
{ Schema =
./schema.dhall
sha256:3269ff2c6eba9856b819f3e7fccd44f2745fdff9d02498e6f0a1474ce650af17
? ./schema.dhall
, Schema/validate =
./validate.dhall
sha256:9e327f316fce0ced3598e14020a8a1ee3bd603a7817cb9e62ceddac3ece10e76
? ./validate.dhall
, Prelude =
./prelude.dhall
sha256:a6036bc38d883450598d1de7c98ead113196fe2db02e9733855668b18096f07b
}

@ -1,8 +0,0 @@
{-
the env env will only be resolved if this file is imported locally, i.e. for
local development.
for remote scenarios the env will fall back to the integrity-protected import.
-}
env:DHALL_PRELUDE
? https://prelude.dhall-lang.org/v20.2.0/package.dhall
sha256:a6036bc38d883450598d1de7c98ead113196fe2db02e9733855668b18096f07b

@ -1,26 +0,0 @@
let Schema =
-- | define a configuration schema.
{ Type =
{ Host : Text
, Port : Natural
, AppName : Text
, LiveMode : Bool
, DevelMode : Bool
, Session : { CookieName : Optional Text, CookieSecret : Text }
, Logger : { Json : Bool, Fmt : Optional Text }
, Registration : { Allowed : Bool }
}
, default =
-- | have sane defaults.
{ Host = ""
, Port = 3000
, AppName = "pcmt"
, LiveMode = False
, DevelMode = False
, Session = { CookieName = None Text, CookieSecret = "secretz" }
, Logger = { Json = True, Fmt = None Text }
, Registration.Allowed = True
}
}
in Schema

@ -1,27 +0,0 @@
let Prelude =
{- this will have to get bumped when prelude is updated -}
./prelude.dhall
sha256:a6036bc38d883450598d1de7c98ead113196fe2db02e9733855668b18096f07b
let Schema =
./schema.dhall
sha256:3269ff2c6eba9856b819f3e7fccd44f2745fdff9d02498e6f0a1474ce650af17
? ./schema.dhall
let Schema/validate
: Schema.Type -> Type
=
-- | define validation.
\(c : Schema.Type) ->
let expected = { validPort = True }
let actual =
{ validPort =
-- | make sure port number belongs to the <1;65535> range.
Prelude.Natural.lessThanEqual 1 c.Port
&& Prelude.Natural.lessThanEqual c.Port 65535
}
in expected === actual
in Schema/validate

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

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

@ -1,8 +1,8 @@
{- 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
https://git.dotya.ml/mirre-mt/pcmt-config-schema/raw/tag/0.0.0/package.dhall
sha256:c82b0904c261d442e5765c2f47d76ad53c3c3ed16ace1b33416cedf98f2f5df0
? https://git.dotya.ml/mirre-mt/pcmt/raw/branch/development/config/schema/package.dhall
? https://git.dotya.ml/mirre-mt/pcmt-config-schema/raw/tag/0.0.0/package.dhall
let Config = ConfigSchema.Schema