mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-18 16:31:26 -07:00
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:
parent
bf7a954f00
commit
d29aecad26
19 changed files with 375 additions and 379 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue