Skip to content

fix(cli): walk every page in firewalls, firewall assignments and elastic-ips list - #100

Open
lbarrosby wants to merge 1 commit into
latitudesh:mainfrom
lbarrosby:fix/list-commands-pagination
Open

lbarrosby wants to merge 1 commit into
latitudesh:mainfrom
lbarrosby:fix/list-commands-pagination

Conversation

@lbarrosby

@lbarrosby lbarrosby commented Nov 7, 2026 •

Copy link
Copy Markdown

Summary

lsh firewalls list, lsh firewalls assignments list (both the team-wide and the --firewall form) and lsh elastic-ips list make a single request with no page[size] / page[number], so they only show the API's first page (20 items) and ignore the global --page-size, --max-items and --no-paginate flags. A team with more than 20 firewalls, assignments or Elastic IPs never sees the rest, and nothing tells the user the list was cut.

Fix

Each command now requests --page-size items per page and walks the SDK Next closures with pagination.Walk, the same way servers list and user-data list already do. --max-items caps the total, and --no-paginate stops after the first page and prints the "Next page" hint to stderr. The request building moved into small listFirewalls / listAssignments / listElasticIPs helpers that take the SDK client, so they can be tested against a local server. Filters (--project, --server, --status) are kept on every page.

Testing

  • TestListFirewallsWalksEveryPage: an httptest server that pages like the API serves 5 firewalls; with --page-size 2 all 5 come back from pages 1, 2, 3 with page[size]=2 on each request; --max-items 3 stops after page 2 and --no-paginate after page 1, both reporting more results.
  • TestListAssignmentsWalksEveryPage: 45 assignments over 3 pages, team-wide and for one firewall.
  • TestListElasticIPsWalksEveryPage: 45 Elastic IPs over 3 pages, with filter[server] sent on every page.
  • End to end with a local fake API holding 45 items per endpoint (no real API or credentials), each command on main vs this branch:
command main this branch
firewalls list 20 45
firewalls assignments list 20 45
elastic-ips list 20 45

(Pointing the CLI at the local server needs #99; I built both binaries with it applied.)

  • go vet ./cmd/... ./internal/..., go test ./... and golangci-lint run ./cmd/firewalls ./cmd/elasticips pass.

AI disclosure: written with the help of Claude Code, reviewed and tested by me.


Note

Low Risk
CLI-only listing behavior with established pagination helpers; no auth or mutation paths changed.

Overview
Fixes incomplete listings for lsh firewalls list, lsh firewalls assignments list (team-wide and --firewall), and lsh elastic-ips list, which previously issued a single API call and only showed the first page (~20 items), ignoring global --page-size, --max-items, and --no-paginate.

Each command now resolves pagination options, sets page[size] / page[number] on requests, and uses pagination.Walk with the SDK’s Next handlers—matching other list commands. Filters (--project, --server, --status) stay on every page; when --no-paginate is set and more pages exist, pagination.PrintNextCursor prints the next page hint.

Logic moves into testable helpers listFirewalls, listAssignments, and listElasticIPs. New httptest cases verify multi-page fetching, max-items / no-paginate behavior, and that filters are sent on each request.

Reviewed by Cursor Bugbot for commit 831428a. Bugbot is set up for automated code reviews on this repo. Configure here.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no actionable issues were found.

Summary

Adds pagination to firewall, firewall assignment, and Elastic IP lists.

  • Firewall lists now collect pages until their limits are reached.
  • Firewall assignment lists now collect pages for both listing views.
  • Elastic IP lists now collect pages while keeping their filters.

Reviews (1) · Last reviewed commit: "fix(cli): walk every page in firewalls, ..." · Reviewed by Greptile

…tic-ips list

These three commands made a single request without page[size] or
page[number], so they showed only the API's first page (20 items) and
ignored --page-size, --max-items and --no-paginate. A team with more
than 20 firewalls, assignments or Elastic IPs never saw the rest.

Request --page-size items per page and drive the SDK Next closures with
pagination.Walk, like servers and user-data list already do.

Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant