Make ldap module optional 84/12384/3 v0.16.1
authorThanh Ha <thanh.ha@linuxfoundation.org>
Fri, 24 Aug 2018 15:38:27 +0000 (11:38 -0400)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Fri, 24 Aug 2018 15:46:17 +0000 (11:46 -0400)
Install via 'pip install lftools[ldap]'.

Change-Id: Ie2206b43b094e1576936ba934268dc0b68fc5a40
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
lftools/cli/__init__.py
lftools/cli/ldap_cli.py
lftools/cli/no_cmd.py [new file with mode: 0644]
releasenotes/notes/ldap-b50f699fc066890f.yaml [new file with mode: 0644]
requirements.txt
setup.cfg

index 1be0deb..21df0ba 100644 (file)
@@ -20,7 +20,6 @@ from lftools.cli.dco import dco
 from lftools.cli.deploy import deploy
 from lftools.cli.infofile import infofile
 from lftools.cli.jenkins import jenkins_cli
-from lftools.cli.ldap_cli import ldap_cli
 from lftools.cli.license import license
 from lftools.cli.nexus import nexus
 from lftools.cli.sign import sign
@@ -51,7 +50,14 @@ cli.add_command(license)
 cli.add_command(nexus)
 cli.add_command(sign)
 cli.add_command(version)
-cli.add_command(ldap_cli, name='ldap')
+
+try:
+    from lftools.cli.ldap_cli import ldap_cli
+    cli.add_command(ldap_cli, name='ldap')
+except ImportError:
+    from lftools.cli.no_cmd import no_ldap as ldap_cli
+    cli.add_command(ldap_cli, name='ldap')
+
 
 try:
     from lftools.openstack.cmd import openstack
index b4bdf77..71ecb10 100644 (file)
@@ -21,6 +21,7 @@ import subprocess
 import sys
 
 import click
+
 import ldap
 
 
diff --git a/lftools/cli/no_cmd.py b/lftools/cli/no_cmd.py
new file mode 100644 (file)
index 0000000..6c45dae
--- /dev/null
@@ -0,0 +1,26 @@
+# -*- code: utf-8 -*-
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2018 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+"""CLI configuration for ldap command."""
+
+__author__ = 'Thanh Ha'
+
+
+import click
+
+
+@click.group()
+@click.pass_context
+def no_ldap(ctx):
+    """(lftools[ldap]) Provides an ldap interface.
+
+    To activate this interface run `pip install lftools[ldap]`.
+    """
+    pass
diff --git a/releasenotes/notes/ldap-b50f699fc066890f.yaml b/releasenotes/notes/ldap-b50f699fc066890f.yaml
new file mode 100644 (file)
index 0000000..6277055
--- /dev/null
@@ -0,0 +1,6 @@
+---
+fixes:
+  - |
+    The v0.16.0 pulled in a new ldap module which breaks if the ldap devel
+    libraries are not available on the system trying to use it. This hotfix
+    makes the ldap module optional.
index bba6259..1f76aec 100644 (file)
@@ -1,5 +1,4 @@
 click
-python-ldap
 pyyaml
 requests~=2.18.0
 ruamel.yaml
index 2cafa32..1d1ed79 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -23,6 +23,8 @@ classifier =
     Programming Language :: Python :: 3.7
 
 [extras]
+ldap =
+    python-ldap~=3.1.0
 openstack =
     shade~=1.27.1