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
1ff03848
Commit
1ff03848
authored
3 years ago
by
stuebinm
Browse files
Options
Downloads
Patches
Plain Diff
server: exneuland wants a token, apparently
parent
cc52022f
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
config.toml
+1
-0
1 addition, 0 deletions
config.toml
server/Main.hs
+7
-13
7 additions, 13 deletions
server/Main.hs
server/Server.hs
+9
-6
9 additions, 6 deletions
server/Server.hs
with
17 additions
and
19 deletions
config.toml
+
1
−
0
View file @
1ff03848
...
...
@@ -8,6 +8,7 @@ tmpdir = "/tmp"
# linting interval in seconds
interval
=
30
exneuland
=
"http://localhost:4000"
token
=
"hello, world!"
[[org]]
slug
=
"divoc"
...
...
This diff is collapsed.
Click to expand it.
server/Main.hs
+
7
−
13
View file @
1ff03848
...
...
@@ -10,14 +10,7 @@
-- | simple server offering linting "as a service"
module
Main
where
import
Universum
(
Container
(
length
),
IO
,
MVar
,
Monad
((
>>=
)),
Num
((
*
)),
Proxy
(
Proxy
),
Text
,
atomically
,
forM_
,
forever
,
map
,
newMVar
,
print
,
putTextLn
,
readMVar
,
view
,
void
,
(
$
),
(
.
))
import
Universum
import
Control.Concurrent
(
threadDelay
)
import
Control.Concurrent.Async
(
async
,
link
,
waitEither_
)
...
...
@@ -49,10 +42,11 @@ import Server (JobStatus, Org (..),
ServerState
,
Sha1
,
emptyState
,
exneuland
,
interval
,
loadConfig
,
orgs
,
port
,
unState
,
verbose
)
orgs
,
port
,
token
,
unState
,
verbose
)
import
Worker
(
Job
(
Job
),
linterThread
)
import
Servant.API
(
Header
)
import
Servant.Client
(
BaseUrl
(
BaseUrl
),
ClientM
,
Scheme
(
Http
),
client
,
mkClientEnv
,
...
...
@@ -60,7 +54,7 @@ import Servant.Client (BaseUrl (BaseUrl),
type
family
PolyEndpoint
method
format
payload
where
PolyEndpoint
Get
format
payload
=
Get
format
payload
PolyEndpoint
Post
format
payload
=
ReqBody
format
payload
:>
Post
'
[
PlainText
]
Text
PolyEndpoint
Post
format
payload
=
Header
"Auth"
Text
:>
ReqBody
format
payload
:>
Post
'
[
PlainText
]
Text
type
MapServiceAPI
method
=
...
...
@@ -92,7 +86,7 @@ server state = jsonAPI @JSON state
app
::
MVar
ServerState
->
Application
app
=
serve
(
Proxy
@
Routes
)
.
server
postNewMaps
::
MapService
->
ClientM
Text
postNewMaps
::
Maybe
Text
->
MapService
->
ClientM
Text
postNewMaps
=
client
(
Proxy
@
(
MapServiceAPI
Post
))
main
::
IO
()
...
...
@@ -123,7 +117,7 @@ main = do
updater
<-
async
$
forever
$
do
done
<-
readMVar
state
res
<-
runClientM
(
postNewMaps
(
MapService
done
))
(
postNewMaps
(
view
token
config
)
(
MapService
done
))
(
mkClientEnv
manager'
(
view
exneuland
config
))
print
res
threadDelay
(
view
interval
config
*
1000000
)
...
...
This diff is collapsed.
Click to expand it.
server/Server.hs
+
9
−
6
View file @
1ff03848
...
...
@@ -19,7 +19,7 @@
module
Server
(
loadConfig
,
Org
(
..
)
,
Sha1
,
Config
,
tmpdir
,
port
,
verbose
,
orgs
,
interval
,
exneuland
,
Config
,
tmpdir
,
port
,
verbose
,
orgs
,
interval
,
exneuland
,
token
,
RemoteRef
(
..
)
,
ServerState
,
emptyState
,
unState
,
JobStatus
(
..
)
...
...
@@ -36,19 +36,19 @@ import Data.Aeson (FromJSON, ToJSON, ToJSONKey (..),
eitherDecodeFileStrict'
)
import
qualified
Data.Aeson
as
A
import
qualified
Data.ByteString.Base64.URL
as
Base64
import
Data.Coerce
(
coerce
)
import
Data.Either.Extra
(
mapLeft
)
import
Data.Functor.Contravariant
(
contramap
)
import
qualified
Data.Map
as
M
import
Lens.Micro.Platform
(
at
,
ix
,
makeLenses
,
traverseOf
)
import
LintConfig
(
LintConfig
'
)
import
Servant
(
FromHttpApiData
)
import
Servant.Client
(
BaseUrl
,
parseBaseUrl
)
import
Servant.Client
(
BaseUrl
,
parseBaseUrl
)
import
Toml
(
BiMap
(
BiMap
),
TomlBiMap
,
TomlBiMapError
(
ArbitraryError
),
TomlCodec
,
prettyTomlDecodeErrors
,
(
.=
))
TomlCodec
,
prettyTomlDecodeErrors
,
(
.=
))
import
qualified
Toml
as
T
import
Data.Either.Extra
(
mapLeft
)
-- | a reference in a remote git repository
data
RemoteRef
=
RemoteRef
...
...
@@ -116,6 +116,7 @@ data Config (loaded :: Bool) = Config
,
_interval
::
Int
-- ^ port to bind to
,
_exneuland
::
BaseUrl
,
_token
::
Maybe
Text
,
_orgs
::
[
Org
loaded
]
}
deriving
Generic
...
...
@@ -150,6 +151,8 @@ configCodec = Config
<*>
T
.
bool
"verbose"
.=
_verbose
<*>
T
.
int
"interval"
.=
_interval
<*>
T
.
match
(
urlBimap
>>>
T
.
_String
)
"exneuland"
.=
_exneuland
-- First is just Maybe but with different semantics
<*>
coerce
(
T
.
first
T
.
text
"token"
)
.=
_token
<*>
T
.
list
orgCodec
"org"
.=
_orgs
-- | a job status (of a specific uuid)
...
...
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