Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

checks: Name the required settings better when running in Docker.

Alex Vandiverb869cb29e0bd
diff --git a/zerver/checks.py b/zerver/checks.py
index 3e81ee6c6a7..a32b4e44017 100644
--- a/zerver/checks.py
+++ b/zerver/checks.py
@@ -34,9 +34,15 @@ def check_required_settings(
):
continue
+ if settings.RUNNING_IN_DOCKER:
+ settings_location = "your Docker environment configuration"
+ setting_display_name = "SETTING_" + setting_name
+ else:
+ settings_location = "/etc/zulip/settings.py"
+ setting_display_name = setting_name
errors.append(
checks.Error(
- f"You must set {setting_name} in /etc/zulip/settings.py",
+ f"You must set {setting_display_name} in {settings_location}",
obj=f"settings.{setting_name}",
id="zulip.E001",
)
diff --git a/zerver/tests/test_checks.py b/zerver/tests/test_checks.py
index a52e58df065..c90bcf76e37 100644
--- a/zerver/tests/test_checks.py
+++ b/zerver/tests/test_checks.py
@@ -19,6 +19,7 @@ class TestChecks(ZulipTestCase):
stack.enter_context(self.assertRaisesRegex(SystemCheckError, test))
call_command("check", stdout=DEVNULL)
+ @override_settings(RUNNING_IN_DOCKER=False)
def test_checks_required_setting(self) -> None:
self.assert_check_with_error(
"(zulip.E001) You must set ZULIP_ADMINISTRATOR in /etc/zulip/settings.py",
@@ -35,6 +36,23 @@ class TestChecks(ZulipTestCase):
ZULIP_ADMINISTRATOR=None,
)
+ @override_settings(RUNNING_IN_DOCKER=True)
+ def test_checks_required_setting_docker(self) -> None:
+ self.assert_check_with_error(
+ "(zulip.E001) You must set SETTING_ZULIP_ADMINISTRATOR in your Docker environment configuration",
+ ZULIP_ADMINISTRATOR="[email protected]",
+ )
+
+ self.assert_check_with_error(
+ "(zulip.E001) You must set SETTING_ZULIP_ADMINISTRATOR in your Docker environment configuration",
+ ZULIP_ADMINISTRATOR="",
+ )
+
+ self.assert_check_with_error(
+ "(zulip.E001) You must set SETTING_ZULIP_ADMINISTRATOR in your Docker environment configuration",
+ ZULIP_ADMINISTRATOR=None,
+ )
+
@override_settings(DEVELOPMENT=False, PRODUCTION=True)
def test_checks_external_host_domain(self) -> None:
message_re = r"\(zulip\.E002\) EXTERNAL_HOST \(\S+\) does not contain a domain part"