gitlab: clean up modules and utils (#3694)

* gitlab: remove dead code in module_utils

* gitlab: use snake_case consistently in methods and functions

* gitlab: use snake_case consistently in variables

* gitlab: fix pep8 indentation issues

* gitlab: add changelog fragment

* gitlab: apply suggestions from code review

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
Co-authored-by: Chris Frage <git@sh0shin.org>

* gitlab: use consistent indentation

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
Co-authored-by: Chris Frage <git@sh0shin.org>
This commit is contained in:
Nejc Habjan 2021-11-16 13:01:32 +01:00 committed by GitHub
parent bf7a954f00
commit d29aecad26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 375 additions and 379 deletions

View file

@ -144,7 +144,7 @@ except Exception:
GITLAB_IMP_ERR = traceback.format_exc()
HAS_GITLAB_PACKAGE = False
from ansible_collections.community.general.plugins.module_utils.gitlab import gitlabAuthentication
from ansible_collections.community.general.plugins.module_utils.gitlab import gitlab_authentication
class GitlabGroupVariables(object):
@ -170,9 +170,13 @@ class GitlabGroupVariables(object):
def create_variable(self, key, value, masked, protected, variable_type):
if self._module.check_mode:
return
return self.group.variables.create({"key": key, "value": value,
"masked": masked, "protected": protected,
"variable_type": variable_type})
return self.group.variables.create({
"key": key,
"value": value,
"masked": masked,
"protected": protected,
"variable_type": variable_type,
})
def update_variable(self, key, var, value, masked, protected, variable_type):
if var.value == value and var.protected == protected and var.masked == masked and var.variable_type == variable_type:
@ -226,11 +230,14 @@ def native_python_main(this_gitlab, purge, var_list, state, module):
existing_variables[index] = None
if state == 'present':
single_change = this_gitlab.update_variable(key,
gitlab_keys[index],
value, masked,
protected,
variable_type)
single_change = this_gitlab.update_variable(
key,
gitlab_keys[index],
value,
masked,
protected,
variable_type,
)
change = single_change or change
if single_change:
return_value['updated'].append(key)
@ -291,7 +298,7 @@ def main():
if not HAS_GITLAB_PACKAGE:
module.fail_json(msg=missing_required_lib("python-gitlab"), exception=GITLAB_IMP_ERR)
gitlab_instance = gitlabAuthentication(module)
gitlab_instance = gitlab_authentication(module)
this_gitlab = GitlabGroupVariables(module=module, gitlab_instance=gitlab_instance)