Skip to content

Comments

Optional YAML configuration for Brig#90

Merged
elverkilde merged 1 commit intodevelopfrom
feature/brig-yaml
Oct 23, 2017
Merged

Optional YAML configuration for Brig#90
elverkilde merged 1 commit intodevelopfrom
feature/brig-yaml

Conversation

@elverkilde
Copy link
Contributor

Adds optional YAML parsing for loading the configuration, the old commandline options are still supported. Only brig and brig-integration is implemented, brig-schema and brig-index needs to be done.

, types-common
, uri-bytestring

test-suite brig-integration
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the motivation of changing the type here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test-suite implies running them as part of the build, which in the current code is worked around by requiring a certain environment variable. In reality, it is actually some sort of mix between a test and an executable.

This way, we should be able to build things (as before) without the need of a hack in the test executable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. Please then also take out this hacky line in the Makefile: https://github.com/wireapp/wire-server/blob/develop/services/brig/Makefile#L31

, port :: Word16
} deriving (Show, Generic)

instance FromJSON Endpoint where
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove unnecessary trailing where keywords?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I just found out through hindent that they aren't required

, setWhitelist :: !(Maybe Whitelist)
, setUserMaxConnections :: !Int64
, setCookieDomain :: !ByteString
, setCookieDomain :: Text
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Text -> !Text to ensure those are defined on startup?

, whitelistUser :: !ByteString
, whitelistPass :: !ByteString
} deriving Show
{ whitelistReq :: !Text
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename as whitelistUrl?

instance FromJSON UserTokenTimeout where
instance FromJSON SessionTokenTimeout where
instance FromJSON AccessTokenTimeout where
instance FromJSON ProviderTokenTimeout where
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove where?

<> showDefault
<> value defaultPath
desc = header "Brig - User Service" <> fullDesc

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of putting this into Main, perhaps move to one of the shared libraries? That would avoid duplication regarding other services & avoid having to add more dependencies to every build-deps in cabal files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, is there an existing lib where this would fit?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

types-common would work I suppose.


instance FromJSON Config where

tests :: Either ParseException Config -> Manager -> DB.ClientState -> Brig -> Cannon -> Galley -> IO TestTree
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we avoid passing a Either ParseException Config into every test? That failure arising from a missing configuration entry or missing ENV variable could be checked before starting any test. Would be better to handle this in Main.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that would have been preferable, but I don't see how this can be resolved in main since the environment vars are pulled directly in the tests.

Would Maybe Config help?

. Cql.addContact h
main = withOpenSSL $ do
iConf <- decodeConfigFile "/etc/wire/brig/integration.yaml"
bConf <- decodeConfigFile "/etc/wire/brig/brig.yaml"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make these locations configurable, please?

<> showDefault
<> value defaultPath
desc = header "Brig - User Service" <> fullDesc

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

types-common would work I suppose.

import Options.Applicative
import System.Directory
import System.Environment (getArgs)
import System.IO (hPutStrLn, stderr)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we instead use our logger as, for instance, here which logs messages in a format that we can already parse?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intended to be used before or without configuring the logging framework. This is basically a temporary workaround, until we decide for either options or config files. When we have one way to configure the app, we will simply terminate it with an error as before this PR.

I would rather remove "logging" from this file, as it is not really an error anyway.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, let's leave it as-is then 👍

docker build -t $(executable) \
-f ../../build/alpine/Dockerfile \
-f Dockerfile \
--build-arg service=$(NAME) \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--build-arg service=$(NAME) \ can be removed.

@elverkilde
Copy link
Contributor Author

elverkilde commented Oct 23, 2017

@tiago-loureiro @jschaul, I did a rebase on develop and squashed.

@elverkilde elverkilde merged commit ef01acb into develop Oct 23, 2017
@elverkilde elverkilde deleted the feature/brig-yaml branch October 23, 2017 14:58
@mdimjasevic mdimjasevic mentioned this pull request Oct 30, 2023
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants