Skip to content

Commit

Permalink
use environment variables to overwrite rest api settings
Browse files Browse the repository at this point in the history
  • Loading branch information
mam10eks committed Dec 10, 2024
1 parent eb290ac commit 0b38e76
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
7 changes: 6 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
"args": [
"run_develop"
],
"env": {
"TIRA_API_BASE_URL": "https://127.0.0.1:8080",
"TIRA_GRPC_BASE_URL": "https://127.0.0.1:8080",
"TIRA_ARCHIVED_URL": "https://127.0.0.1:8080"
},
"django": true,
"autoStartBrowser": false,
"program": "${workspaceFolder:Backend}/src/manage.py"
Expand Down Expand Up @@ -144,7 +149,7 @@
},

// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"
"remoteUser": "ubuntu",

// Needed for parts of the python-client that build and run docker containers
"privileged": true,
Expand Down
9 changes: 9 additions & 0 deletions application/config/tira-application-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,12 @@ django_secret: !ENV ${DJANGO_SECRET:change-me!}
grpc_host: local
host_grpc_port: 50051
application_grpc_port: 50052

tira_rest_api:
base_url: !ENV ${TIRA_API_BASE_URL:https://www.tira.io}
grpc_url: !ENV ${TIRA_GRPC_BASE_URL:https://www.tira.io}
archived_url: !ENV ${TIRA_ARCHIVED_URL:https://archive.tira.io}
login_url: !ENV ${TIRA_LOGIN_URL:https://www.tira.io}
logout_url: !ENV ${TIRA_LOGOUT_URL:https://www.tira.io}
disraptor_url: !ENV ${TIRA_DISRAPTOR_URL:https://www.tira.io}
notifications_url: !ENV ${TIRA_NOTIFICATIONS_URL:https://www.tira.io}
19 changes: 7 additions & 12 deletions application/src/django_admin/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,19 +399,14 @@ def logger_config(log_dir: Path):
}

WELL_KNOWN = {
"api": "https://www.tira.io",
"grpc": "https://www.tira.io",
"archived": "https://archive.tira.io",
"login": "https://www.tira.io",
"logout": "https://www.tira.io",
"notifications": "fooo",
"disraptorURL": "https://www.tira.io",
"api": custom_settings['tira_rest_api']['base_url'],
"grpc": custom_settings['tira_rest_api']['grpc_url'],
"archived": custom_settings['tira_rest_api']['archived_url'],
"login": custom_settings['tira_rest_api']['login_url'],
"logout": custom_settings['tira_rest_api']['logout_url'],
"notifications": custom_settings['tira_rest_api']['notifications_url'],
"disraptorURL": custom_settings['tira_rest_api']['disraptor_url'],
}

if "well_known" in custom_settings:
for k in list(WELL_KNOWN.keys()):
if k in custom_settings["well_known"]:
WELL_KNOWN[k] = custom_settings["well_known"][k]

CODE_SUBMISSION_REPOSITORY_NAMESPACE = "tira-io"
CSRF_TRUSTED_ORIGINS = ["https://127.0.0.1:8082", "https://127.0.0.1:8080", "https://127.0.0.1:8081"]
4 changes: 1 addition & 3 deletions application/src/tira_app/endpoints/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

rest_api_version = "v1.0.0-draft"

WELL_KNOWN = {i: settings.WELL_KNOWN[i] for i in ["api", "archived", "login", "logout", "disraptorURL", "grpc"]}


try:
SOFTWARE_COUNT = len(json.loads(public_submissions(None).content.decode("UTF-8")))
Expand Down Expand Up @@ -60,7 +58,7 @@ def info_endpoint(request: Request) -> Response:

@api_view(["GET"])
def well_known_endpoint(request: Request) -> Response:
return Response(WELL_KNOWN)
return Response(settings.WELL_KNOWN)


endpoints = [
Expand Down

0 comments on commit 0b38e76

Please sign in to comment.