Use ScanAndCollect for paging through all results

This code change replaces manual pagination logic with a new utility function called ScanAndCollect across multiple GitLab API data sources.

Previously, the code manually handled pagination by setting up page numbers, making API calls in loops, collecting results, and checking for next pages. This repetitive pattern was scattered throughout different files for fetching cluster agents, group memberships, variables, environments, runners, job token scopes, project issues, and SSH keys.

The new approach uses gitlab.ScanAndCollect() which takes a function that makes the API call and automatically handles all the pagination logic internally. This eliminates the need for manual page tracking, loop management, and result accumulation.

The benefits are cleaner, more maintainable code with less duplication, reduced chance of pagination bugs, and a consistent pattern across all data sources. The functionality remains exactly the same from a user perspective - it still fetches all pages of results - but the implementation is much simpler and more reliable.

Merge request reports

Loading
Loading