Skip to content

Commit

Permalink
#228: Make certain config options optional
Browse files Browse the repository at this point in the history
- Explained in the docstring
  • Loading branch information
MRichards99 committed Apr 30, 2021
1 parent 0c68549 commit 302042f
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions datagateway_api/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,27 @@ def _check_config_items_exist(self):
"""
A function to check that all config options exist before getting too far into
the setup of the API. This check takes the backend into account, meaning only
the config options for the backend used is required
Config options used for testing are not checked here as they should only be used
during tests, not in the typical running of the API
the config options for the backend used is required.
If a config option is missing, this will be picked up in `get_config_value()` by
exiting the application
Config options used for testing are not checked here as they should only be used
during tests, not in the typical running of the API.
Some options used when running the API (host, debug_mode etc.) aren't mandatory
when running the API in production (these options aren't used in the `wsgi.py`
entrypoint). As a result, they're not present in `config_keys`. However, they
are required when using `main.py` as an entrypoint. In any case of these
specific missing config options when using that entrypoint, they are checked at
API startup so any missing options will be caught quickly.
"""
# These keys are non-backend specific and therefore are mandatory for all uses
config_keys = [
APIConfigOptions.BACKEND,
APIConfigOptions.DEBUG_MODE,
APIConfigOptions.FLASK_RELOADER,
APIConfigOptions.GENERATE_SWAGGER,
APIConfigOptions.HOST,
APIConfigOptions.LOG_LEVEL,
APIConfigOptions.LOG_LOCATION,
APIConfigOptions.PORT,
]

if self.get_config_value(APIConfigOptions.BACKEND) == "python_icat":
Expand Down

0 comments on commit 302042f

Please sign in to comment.