From afaf9a7c57214b1b27ce8dc7d7eeb3fd623ddcdb Mon Sep 17 00:00:00 2001 From: Suejung Shin Date: Mon, 13 Jan 2025 12:11:15 -0800 Subject: [PATCH] fix: Handle disabled shelter --- codecov/settings_base.py | 1 + codecov/settings_enterprise.py | 2 ++ utils/shelter.py | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/codecov/settings_base.py b/codecov/settings_base.py index 721bbfa0ca..0ac2546778 100644 --- a/codecov/settings_base.py +++ b/codecov/settings_base.py @@ -395,6 +395,7 @@ ) SHELTER_SHARED_SECRET = get_config("setup", "shelter_shared_secret", default=None) +SHELTER_ENABLED = get_config("setup", "shelter_enabled", default=True) SENTRY_ENV = os.environ.get("CODECOV_ENV", False) SENTRY_DSN = os.environ.get("SERVICES__SENTRY__SERVER_DSN", None) diff --git a/codecov/settings_enterprise.py b/codecov/settings_enterprise.py index 7af6c9db00..5fd3991d40 100644 --- a/codecov/settings_enterprise.py +++ b/codecov/settings_enterprise.py @@ -72,3 +72,5 @@ ] GUEST_ACCESS = get_config("setup", "guest_access", default=True) + +SHELTER_ENABLED = get_config("setup", "shelter_enabled", default=False) diff --git a/utils/shelter.py b/utils/shelter.py index 784a2ee6ce..f34a847b8b 100644 --- a/utils/shelter.py +++ b/utils/shelter.py @@ -23,6 +23,9 @@ def get_instance(cls) -> "ShelterPubsub": return cls._instance def __init__(self) -> None: + if not settings.SHELTER_ENABLED: + return + if not self.pubsub_publisher: self.pubsub_publisher = pubsub_v1.PublisherClient() pubsub_project_id: str = settings.SHELTER_PUBSUB_PROJECT_ID @@ -32,6 +35,9 @@ def __init__(self) -> None: self.topic_path = self.pubsub_publisher.topic_path(pubsub_project_id, topic_id) def publish(self, data: Dict[str, Any]) -> None: + if not settings.SHELTER_ENABLED: + return + try: self.pubsub_publisher.publish( self.topic_path,