[feat] Add cloud load-zone list command - #6142
Conversation
Add a new `k6 cloud load-zone list` subcommand that lists the load zones available in the configured Grafana Cloud k6 stack, mirroring the existing `cloud project list` command. Supports table and --json output. The table surfaces each zone's k6 load zone ID, name, whether it is a public (Grafana-managed) or private zone, and its availability. The `public` and `available` flags are not yet modeled by the cloud OpenAPI SDK, so they are read best-effort from the untyped response fields and default to false when absent.
- Name ListLoadZones' error return so a body-close error from closeResponse propagates instead of being silently dropped. - Extract the shared v6 client setup (config load, login check, client creation, stack ID wiring) into newCloudV6ClientFromConfig and a cloudStackName helper, used by both `cloud project list` and `cloud load-zone list` instead of duplicating ~35 lines. - Add a test covering the best-effort default: a load zone that omits the untyped public/available fields must default them to false. - Rename cloud_loadzone*.go to cloud_load_zone*.go to match the command spelling and the test file name.
| Public: boolFromAny(zone.AdditionalProperties["public"]), | ||
| Available: boolFromAny(zone.AdditionalProperties["available"]), |
There was a problem hiding this comment.
I see why AdditionalProperties is needed with the currently pinned generated client. AI pointed out that in newer version of k6-cloud-openapi-client-go those are zone's fields directly. Would it be possible, and reasonably easy to bump k6-cloud-openapi-client-go as part of this PR? That would let us use its typed Public and Available fields instead?
If the dependency update must happen separately, could we document that follow-up and reconsider whether silently defaulting required fields is the desired behavior?
- Route cmdCloudTestList.run() through the shared newCloudV6ClientFromConfig helper too, so project, test, and load-zone list all use one setup path instead of each carrying its own config load / auth check / client construction / stack-ID wiring. - Expand the load-zone public/available comment into a TODO(#6142) tracking the k6-cloud-openapi-client-go bump that will replace the untyped AdditionalProperties reads with the SDK's typed fields, and note that both are required API fields so the false default only guards a contract violation.
|
@dgzlopes, how about |
|
|
@dgzlopes could you please resolve conflicts? 🙇 |
…-list # Conflicts: # internal/cmd/cloud_loadtest_list.go # internal/cmd/cloud_project_list.go
Co-authored-by: Joan López de la Franca Beltran <5459617+joanlopez@users.noreply.github.com>
Co-authored-by: Joan López de la Franca Beltran <5459617+joanlopez@users.noreply.github.com>
Brings the branch up to date with master (5880ca9) and resolves the overlap with the cloud changes that landed in the meantime: - grafana#6142 added `k6 cloud load-zone`, whose constructor took the `*cmdCloud` this branch removes. `getCmdCloudLoadZone` now takes a `*state.GlobalState`, like the `project` and `test` constructors already do here. - grafana#6208 dropped the run flag set from the parent `k6 cloud` command and pinned that with a test. This branch had bound those flags to throwaway values to keep the help output unchanged, which is now both unnecessary and wrong, so that block is gone. - grafana#6171 added `--no-cloud-logs`. Its validation stays in `cmdCloudRun.preRun`, followed by `applyCloudEnvOverrides` instead of the parent's `preRun`. - master's new `newCloudV6ClientFromConfig` and `cloudStackName` helpers are kept as they are. No behaviour change beyond what the merged commits already do.
What?
Add a new
k6 cloud load-zone listsubcommand that lists the load zones available in the configured Grafana Cloud k6 stack, mirroring the existingcloud project listcommand. Supports table and --json output.Why?
My agent should have access to this information... so it can actually tell me Private Load Zone X is usable.
Checklist
make check) and all pass.Checklist: Documentation (only for k6 maintainers and if relevant)
Please do not merge this PR until the following items are filled out.
Related PR(s)/Issue(s)