Skip to content

Commit

Permalink
fix: disable pusher when env variables are not set (#2434)
Browse files Browse the repository at this point in the history
  • Loading branch information
talboren authored Nov 11, 2024
1 parent 599e4ae commit 8d34713
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
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

0 comments on commit 8d34713

Please sign in to comment.