summaryrefslogtreecommitdiff
path: root/server/Server.hs
diff options
context:
space:
mode:
authorstuebinm2022-02-16 20:28:46 +0100
committerstuebinm2022-03-19 19:26:32 +0100
commit1ff03848753ed4881d02289ca9236ad4d2e2853a (patch)
treec932169698b1ff366c266155fe771e78d516d428 /server/Server.hs
parentcc52022f3b099287f0ac57eb514753202ef47db2 (diff)
server: exneuland wants a token, apparently
Diffstat (limited to 'server/Server.hs')
-rw-r--r--server/Server.hs15
1 files changed, 9 insertions, 6 deletions
diff --git a/server/Server.hs b/server/Server.hs
index ef01b88..8f09ac7 100644
--- a/server/Server.hs
+++ b/server/Server.hs
@@ -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)