Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disable pusher when env variables are not set #2434

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions keep/api/core/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# Just a fake random tenant id
SINGLE_TENANT_UUID = "keep"
SINGLE_TENANT_EMAIL = "admin@keephq"
PUSHER_DISABLED = os.environ.get("PUSHER_DISABLED", "false") == "true"


async def extract_generic_body(request: Request) -> dict | bytes | FormData:
Expand All @@ -36,20 +37,31 @@ async def extract_generic_body(request: Request) -> dict | bytes | FormData:


def get_pusher_client() -> Pusher | None:
if os.environ.get("PUSHER_DISABLED", "false") == "true":
pusher_host = os.environ.get("PUSHER_HOST")
pusher_app_id = os.environ.get("PUSHER_APP_ID")
pusher_app_key = os.environ.get("PUSHER_APP_KEY")
pusher_app_secret = os.environ.get("PUSHER_APP_SECRET")
if (
PUSHER_DISABLED
or pusher_host is None
or pusher_app_id is None
or pusher_app_key is None
or pusher_app_secret is None
):
logger.debug("Pusher is disabled or missing environment variables")
return None

# TODO: defaults on open source no docker
return Pusher(
host=os.environ.get("PUSHER_HOST"),
host=pusher_host,
port=(
int(os.environ.get("PUSHER_PORT"))
if os.environ.get("PUSHER_PORT")
else None
),
app_id=os.environ.get("PUSHER_APP_ID"),
key=os.environ.get("PUSHER_APP_KEY"),
secret=os.environ.get("PUSHER_APP_SECRET"),
app_id=pusher_app_id,
key=pusher_app_key,
secret=pusher_app_secret,
ssl=False if os.environ.get("PUSHER_USE_SSL", False) is False else True,
cluster=os.environ.get("PUSHER_CLUSTER"),
)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "keep"
version = "0.28.4"
version = "0.28.5"
description = "Alerting. for developers, by developers."
authors = ["Keep Alerting LTD"]
readme = "README.md"
Expand Down
Loading