mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-19 17:01:25 -07:00
fix(modules/gitlab_runner): Use correct argument to list all runners (#7790)
* fix(modules/gitlab_runner): Use correct argument to list all runners python-gitlab 4.0.0 removed support for the `as_list=False` parameter. This functionality is now available as `iterator=True`. Without this change, the module actually only retrieves the first 20 results, which can lead to non-idempotent behavior, such as registering a runner again. * Add changelog entry (#7790) * gitlab_runner: Check python-gitlab version when listing runners * gitlab: Add list_all_kwargs variable to module_utils * refactor(gitlab modules): use list_all_kwargs where it helps (#7790) I did not change every instance of all=True or all=False, only those which could obviously benefit from simplifying: * Code using `all=True` but then searching for any items that match a condition (no need to collect the full list). * Code that basically reimplements `all=True` with manual pagination. (These could be changed to `all=True`, but `list_all_kwargs` also sets per_page to 100, to gather data faster.) * gitlab_instance_variable: Use list_all_kwargs * Add new changelog entry for gitlab module changes (#7790)
This commit is contained in:
parent
f6d0b35bb7
commit
787fa46217
11 changed files with 65 additions and 54 deletions
|
@ -138,7 +138,8 @@ instance_variable:
|
|||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.api import basic_auth_argument_spec
|
||||
from ansible_collections.community.general.plugins.module_utils.gitlab import (
|
||||
auth_argument_spec, gitlab_authentication, filter_returned_variables
|
||||
auth_argument_spec, gitlab_authentication, filter_returned_variables,
|
||||
list_all_kwargs
|
||||
)
|
||||
|
||||
|
||||
|
@ -149,14 +150,7 @@ class GitlabInstanceVariables(object):
|
|||
self._module = module
|
||||
|
||||
def list_all_instance_variables(self):
|
||||
page_nb = 1
|
||||
variables = []
|
||||
gl_varibales_page = self.instance.variables.list(page=page_nb)
|
||||
while len(gl_varibales_page) > 0:
|
||||
variables += gl_varibales_page
|
||||
page_nb += 1
|
||||
gl_varibales_page = self.instance.variables.list(page=page_nb)
|
||||
return variables
|
||||
return list(self.instance.variables.list(**list_all_kwargs))
|
||||
|
||||
def create_variable(self, var_obj):
|
||||
if self._module.check_mode:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue