Initialize OpenshiftGroupsSync attributes early (#165)

* Initialize OpenshiftGroupsSync attributes early

The fail_json() method calls close_connection(), but this can fail when
the python-ldap library is not installed as close_connection() gets
called before the __ldap_connection attribute has been defined.

* Use already defined virtualenv_command

* Fix tests

* Add changelog fragment
This commit is contained in:
Mike Graves
2022-05-12 17:13:59 -04:00
committed by GitHub
parent 15fff541b1
commit 5545c0f9ae
4 changed files with 54 additions and 10 deletions

View File

@@ -267,6 +267,15 @@ class OpenshiftGroupsSync(K8sAnsibleMixin):
def __init__(self, module):
self.module = module
self.params = self.module.params
self.check_mode = self.module.check_mode
self.__k8s_group_api = None
self.__ldap_connection = None
self.host = None
self.port = None
self.netlocation = None
self.scheme = None
self.config = self.params.get("sync_config")
if not HAS_KUBERNETES_COLLECTION:
self.module.fail_json(
@@ -282,18 +291,8 @@ class OpenshiftGroupsSync(K8sAnsibleMixin):
super(OpenshiftGroupsSync, self).__init__(self.module)
self.params = self.module.params
self.check_mode = self.module.check_mode
self.client = get_api_client(self.module)
self.__k8s_group_api = None
self.__ldap_connection = None
self.host = None
self.port = None
self.netlocation = None
self.scheme = None
self.config = self.params.get("sync_config")
@property
def k8s_group_api(self):
if not self.__k8s_group_api: