From 1ff03848753ed4881d02289ca9236ad4d2e2853a Mon Sep 17 00:00:00 2001 From: stuebinm Date: Wed, 16 Feb 2022 20:28:46 +0100 Subject: server: exneuland wants a token, apparently --- server/Server.hs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'server/Server.hs') 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) -- cgit v1.2.3