-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DWPF-1603 Codebase changes for platform migration (#503)
- Loading branch information
Showing
16 changed files
with
1,338 additions
and
2,203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
DJANGO_SETTINGS_MODULE=config.settings.ci | ||
DATABASE_URL=psql://postgres:postgres@db:5432/fido | ||
FLASK_CONFIG=testing | ||
SECRET_KEY=used_for_testing | ||
ALLOWED_HOSTS="*" | ||
DEBUG=False | ||
DATABASE_URL=psql://postgres:postgres@db:5432/fido | ||
REDIS_ENDPOINT=redis://redis:6379 | ||
AUTHBROKER_CLIENT_ID= | ||
AUTHBROKER_CLIENT_SECRET= | ||
AUTHBROKER_URL= | ||
DEBUG=False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,11 @@ | ||
import logging | ||
import sys | ||
|
||
import requests | ||
from django_log_formatter_ecs import ECSFormatter | ||
|
||
from .base import * # noqa | ||
|
||
|
||
CAN_ELEVATE_SSO_USER_PERMISSIONS = True | ||
CAN_CREATE_TEST_USER = True | ||
|
||
FRONT_END_SERVER = env( | ||
"FRONT_END_SERVER", | ||
default="http://localhost:3000", | ||
) | ||
|
||
AUTHENTICATION_BACKENDS += [ | ||
"user.backends.CustomAuthbrokerBackend", | ||
] | ||
|
||
ASYNC_FILE_UPLOAD = False | ||
|
||
LOG_TO_ELK = env.bool("LOG_TO_ELK", default=False) | ||
ELK_ADDRESS = env("ELK_ADDRESS", default=None) | ||
|
||
if LOG_TO_ELK: | ||
|
||
class LogstashHTTPHandler(logging.Handler): | ||
def emit(self, record): | ||
log_entry = self.format(record) | ||
|
||
return requests.post( | ||
ELK_ADDRESS, | ||
data="{}".format(log_entry), | ||
headers={"Content-type": "application/json"}, | ||
).content | ||
|
||
LOGGING = { | ||
"version": 1, | ||
"disable_existing_loggers": False, | ||
"formatters": { | ||
"ecs_formatter": { | ||
"()": ECSFormatter, | ||
}, | ||
}, | ||
"handlers": { | ||
"stdout": { | ||
"class": "logging.StreamHandler", | ||
"stream": sys.stdout, | ||
}, | ||
"logstash": { | ||
"()": LogstashHTTPHandler, | ||
"formatter": "ecs_formatter", | ||
}, | ||
}, | ||
"loggers": { | ||
"django.request": { | ||
"handlers": [ | ||
"stdout", | ||
"logstash", | ||
], | ||
"level": "WARNING", | ||
"propagate": True, | ||
}, | ||
}, | ||
} | ||
else: | ||
LOGGING = { | ||
"version": 1, | ||
"disable_existing_loggers": False, | ||
"handlers": { | ||
"stdout": { | ||
"class": "logging.StreamHandler", | ||
"stream": sys.stdout, | ||
}, | ||
}, | ||
"root": { | ||
"handlers": ["stdout"], | ||
"level": os.getenv("ROOT_LOG_LEVEL", "INFO"), | ||
}, | ||
"loggers": { | ||
"django": { | ||
"handlers": [ | ||
"stdout", | ||
], | ||
"level": os.getenv("DJANGO_LOG_LEVEL", "INFO"), | ||
"propagate": True, | ||
}, | ||
"forecast.import_csv": { | ||
"handlers": [ | ||
"stdout", | ||
], | ||
"level": "INFO", | ||
"propagate": True, | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import dj_database_url | ||
from dbt_copilot_python.database import database_url_from_env | ||
from dbt_copilot_python.network import setup_allowed_hosts | ||
from dbt_copilot_python.utility import is_copilot | ||
|
||
from .base import * | ||
|
||
|
||
# TODO (DWPF-1696): Remove ECS formatter | ||
LOGGING["handlers"]["console"]["formatter"] = "ecs" | ||
|
||
if is_copilot(): | ||
ALLOWED_HOSTS = setup_allowed_hosts(ALLOWED_HOSTS) | ||
|
||
DATABASES["default"] = dj_database_url.config( | ||
default=database_url_from_env("DATABASE_CREDENTIALS") | ||
) | ||
|
||
LOGGING["handlers"]["console"]["formatter"] = "asim" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.