Skip to content

Commit

Permalink
#210: Make all config keys use same casing
Browse files Browse the repository at this point in the history
  • Loading branch information
MRichards99 committed Apr 20, 2021
1 parent 3c40ccb commit c1a02e5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ pre-commit install
Depending on the backend you want to use (either `db` or `python_icat`, more details
about backends [here](#backends)) the connection URL for the backend needs to be set.
These are set in `config.json` (an example file is provided in the base directory of
this repository). While both `DB_URL` and `ICAT_URL` should have values assigned to them
(for best practice), `DB_URL` will only be used for the database backend, and `ICAT_URL`
this repository). While both `db_url` and `icat_url` should have values assigned to them
(for best practice), `db_url` will only be used for the database backend, and `icat_url`
will only be used for the Python ICAT backend. Copy `config.json.example` to
`config.json` and set the values as needed. If you need to create an instance of ICAT,
there are a number of markdown-formatted tutorials that can be found on the
Expand Down Expand Up @@ -706,7 +706,7 @@ flags `-s` or `--seed` for the seed, and `-y` or `--years` for the number of yea
example: `python -m util.icat_db_generator -s 4 -y 10` Would set the seed to 4 and
generate 10 years of data.

This uses code from the API's Database Backend, so a suitable `DB_URL` should be
This uses code from the API's Database Backend, so a suitable `db_url` should be
configured in `config.json`.


Expand Down
8 changes: 4 additions & 4 deletions datagateway_api/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def set_backend_type(self, backend_type):

def get_db_url(self):
try:
return self.config["DB_URL"]
return self.config["db_url"]
except KeyError:
sys.exit("Missing config value, DB_URL")
sys.exit("Missing config value, db_url")

def is_flask_reloader(self):
try:
Expand All @@ -61,9 +61,9 @@ def is_flask_reloader(self):

def get_icat_url(self):
try:
return self.config["ICAT_URL"]
return self.config["icat_url"]
except KeyError:
sys.exit("Missing config value, ICAT_URL")
sys.exit("Missing config value, icat_url")

def get_icat_check_cert(self):
try:
Expand Down
2 changes: 1 addition & 1 deletion datagateway_api/common/query_filter_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get_query_filter(request_filter):
:raises FilterError: If the filter name is not recognised
"""

backend_type = config.get_backend_type()
backend_type = config.get_config_value("backend")
if backend_type == "db":
from datagateway_api.common.database.filters import (
DatabaseDistinctFieldFilter as DistinctFieldFilter,
Expand Down
4 changes: 2 additions & 2 deletions datagateway_api/config.json.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"backend": "db",
"DB_URL": "mysql+pymysql://icatdbuser:icatdbuserpw@localhost:3306/icatdb",
"db_url": "mysql+pymysql://icatdbuser:icatdbuserpw@localhost:3306/icatdb",
"flask_reloader": false,
"ICAT_URL": "https://localhost:8181",
"icat_url": "https://localhost:8181",
"icat_check_cert": false,
"log_level": "WARN",
"log_location": "/home/runner/work/datagateway-api/datagateway-api/logs.log",
Expand Down

0 comments on commit c1a02e5

Please sign in to comment.