Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
walint
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
hub
walint
Commits
a55e0ce9
Commit
a55e0ce9
authored
3 years ago
by
stuebinm
Browse files
Options
Downloads
Patches
Plain Diff
server: simple toml config
parent
f10f80a2
No related branches found
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
config.toml
+8
-0
8 additions, 0 deletions
config.toml
package.yaml
+1
-0
1 addition, 0 deletions
package.yaml
server/Main.hs
+2
-3
2 additions, 3 deletions
server/Main.hs
server/Server.hs
+37
-14
37 additions, 14 deletions
server/Server.hs
walint.cabal
+1
-0
1 addition, 0 deletions
walint.cabal
with
49 additions
and
17 deletions
config.toml
0 → 100644
+
8
−
0
View file @
a55e0ce9
port
=
8080
tmpdir
=
"/tmp"
entrypoint
=
"main.json"
lintconfig
=
"./config.json"
This diff is collapsed.
Click to expand it.
package.yaml
+
1
−
0
View file @
a55e0ce9
...
...
@@ -73,3 +73,4 @@ executables:
-
containers
-
microlens
-
microlens-th
-
tomland
This diff is collapsed.
Click to expand it.
server/Main.hs
+
2
−
3
View file @
a55e0ce9
...
...
@@ -71,7 +71,6 @@ app config =
main
::
IO
()
main
=
do
config'
<-
loadConfig
"./config.toml"
state
<-
newMVar
defaultState
let
config
=
Config
"/tmp"
8080
"main.json"
"./config.json"
config'
<-
loadConfig
config
run
(
port
config
)
(
app
config'
state
)
run
(
port
config'
)
(
app
config'
state
)
This diff is collapsed.
Click to expand it.
server/Server.hs
+
37
−
14
View file @
a55e0ce9
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
...
...
@@ -23,6 +27,10 @@ import GHC.Generics (Generic)
import
Lens.Micro
(
over
)
import
Lens.Micro.TH
import
LintConfig
(
LintConfig
'
)
import
System.Exit.Compat
(
exitFailure
)
import
Toml
(
TomlCodec
)
import
qualified
Toml
import
Toml.Codec
((
.=
))
-- | a reference in a remote git repository
...
...
@@ -36,14 +44,21 @@ type family ConfigRes (b :: Bool) a where
ConfigRes
False
a
=
FilePath
-- | the server's configuration
data
Config
l
=
Config
data
Config
(
loaded
::
Bool
)
=
Config
{
tmpdir
::
FilePath
-- ^ dir to clone git things in
,
port
::
Int
-- ^ port to bind to
,
entrypoint
::
FilePath
,
lintconfig
::
ConfigRes
l
LintConfig'
}
,
lintconfig
::
ConfigRes
loaded
LintConfig'
}
deriving
Generic
configCodec
::
TomlCodec
(
Config
False
)
configCodec
=
Config
<$>
Toml
.
string
"tmpdir"
.=
tmpdir
<*>
Toml
.
int
"port"
.=
port
<*>
Toml
.
string
"entrypoint"
.=
entrypoint
<*>
Toml
.
string
"lintconfig"
.=
lintconfig
data
JobStatus
=
Pending
|
Linted
DirResult
|
Failed
Text
...
...
@@ -59,9 +74,17 @@ makeLenses ''State
defaultState
::
State
defaultState
=
State
mempty
mempty
loadConfig
::
FilePath
->
IO
(
Config
True
)
loadConfig
path
=
do
res
<-
Toml
.
decodeFileEither
configCodec
path
case
res
of
Right
config
->
loadConfig'
config
Left
err
->
do
print
err
exitFailure
loadConfig
::
Config
False
->
IO
(
Config
True
)
loadConfig
config
=
do
loadConfig
'
::
Config
False
->
IO
(
Config
True
)
loadConfig
'
config
=
do
loaded
<-
LB
.
readFile
(
lintconfig
config
)
>>=
\
res
->
case
eitherDecode
res
::
Either
String
LintConfig'
of
Left
err
->
error
$
"config file invalid: "
<>
err
...
...
This diff is collapsed.
Click to expand it.
walint.cabal
+
1
−
0
View file @
a55e0ce9
...
...
@@ -88,6 +88,7 @@ executable server
, string-conversions
, text
, time
, tomland
, uuid
, wai
, walint
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment