Problem
kosli list environments currently calls GET /api/v2/environments/{org} with no query parameters and renders the full, unpaginated array. This doesn't scale for orgs with many environments and ignores the pagination/filtering parameters the API now exposes.
API parameters now available
From https://app.kosli.com/api/v2/openapi.json — GET /environments/{org}:
| Parameter |
Type |
Notes |
page |
int (≥1) |
Page number |
per_page |
int (1–50) |
Page size |
sort |
enum |
EnvironmentSortField, default name |
sort_direction |
enum |
asc / desc, default asc |
space_id |
[]string |
Filter by space; repeatable (OR) |
name |
string |
Case-insensitive substring match |
type |
[]enum |
Filter by env type (K8S, ECS, ...); repeatable |
tag |
[]string |
Filter by key or key:value; repeatable |
Proposed CLI changes
Add flags to kosli list environments mirroring the API:
--page (int, default 1)
--page-size (int, default e.g. 25; max 50)
--sort (string)
--sort-direction (string, asc|desc)
--space-id (stringSlice, repeatable)
--name (string)
--type (stringSlice, repeatable)
--tag (stringSlice, repeatable)
Pass these through as query parameters on the GET request. Default behaviour becomes paginated.
Breaking change consideration
Today the command returns all environments in one call. Introducing default pagination changes behaviour for users who rely on getting the full list (e.g. piping JSON to jq). Options:
- Ship as breaking change under CLI V3 and document migration: use
--page to iterate, or a future --all flag.
- Add
--all flag that auto-paginates and concatenates, for parity with current behaviour.
Definition of Done
References
- Current command:
cmd/kosli/listEnvironments.go
Problem
kosli list environmentscurrently callsGET /api/v2/environments/{org}with no query parameters and renders the full, unpaginated array. This doesn't scale for orgs with many environments and ignores the pagination/filtering parameters the API now exposes.API parameters now available
From
https://app.kosli.com/api/v2/openapi.json—GET /environments/{org}:pageper_pagesortEnvironmentSortField, defaultnamesort_directionasc/desc, defaultascspace_idnametypetagkeyorkey:value; repeatableProposed CLI changes
Add flags to
kosli list environmentsmirroring the API:--page(int, default 1)--page-size(int, default e.g. 25; max 50)--sort(string)--sort-direction(string,asc|desc)--space-id(stringSlice, repeatable)--name(string)--type(stringSlice, repeatable)--tag(stringSlice, repeatable)Pass these through as query parameters on the GET request. Default behaviour becomes paginated.
Breaking change consideration
Today the command returns all environments in one call. Introducing default pagination changes behaviour for users who rely on getting the full list (e.g. piping JSON to
jq). Options:--pageto iterate, or a future--allflag.--allflag that auto-paginates and concatenates, for parity with current behaviour.Definition of Done
cmd/kosli/listEnvironments.goand wired into the request URLEnvironmentListResponse) as well as legacy array shape, or commit fully to paginated shape under V3--page/--page-size, each filter flag, sortkosli list environments --helpdocuments new flagsMIGRATING-v3.mdReferences
cmd/kosli/listEnvironments.go