diff options
| author | 2024-08-19 12:11:31 +0100 | |
|---|---|---|
| committer | 2024-08-19 12:11:31 +0100 | |
| commit | c63b74bd0290b5adcc913b9bf0f5465ae79d5d77 (patch) | |
| tree | ad5ed1c92f09e18846b5553e6be8b067d328cdc2 /arthur/exts/directory/ldap.py | |
| parent | Allow loading the bot without a github_token set (diff) | |
Allow loading the bot without LDAP env vars set
Diffstat (limited to 'arthur/exts/directory/ldap.py')
| -rw-r--r-- | arthur/exts/directory/ldap.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/arthur/exts/directory/ldap.py b/arthur/exts/directory/ldap.py index dd2fc6c..70fe1ab 100644 --- a/arthur/exts/directory/ldap.py +++ b/arthur/exts/directory/ldap.py @@ -427,10 +427,23 @@ class LDAP(commands.Cog): async def setup(bot: KingArthur) -> None: """Add the extension to the bot.""" - if ldap.BONSAI_AVAILABLE and freeipa.BONSAI_AVAILABLE and CONFIG.enable_ldap: - await bot.add_cog(LDAP(bot)) - else: + if not all(ldap.BONSAI_AVAILABLE, freeipa.BONSAI_AVAILABLE, CONFIG.enable_ldap): logger.warning( "Not loading LDAP sync utilities as LDAP dependencies are not available " "or LDAP is disabled by config, see README.md for more." ) + return + if not all( + CONFIG.ldap_host, + CONFIG.ldap_bind_password, + CONFIG.ldap_certificate_location, + CONFIG.keycloak_address, + CONFIG.keycloak_password, + ): + logger.warning( + "Not loading LDAP sync utilities as one or more LDAP environment variables" + "are not set, see README.md for more." + ) + return + + await bot.add_cog(LDAP(bot)) |