Auto-detect organizations for org usage and Prometheus - #347
Open
sdairs wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aligns cloud org prometheus and cloud org usage with the rest of the cloud CLI surface by making organization selection optional via --org-id, falling back to the existing single-organization auto-detection path when omitted. It also updates documentation and adds both clap parsing and real-binary request-path coverage to prevent regressions.
Changes:
- Change
cloud org prometheusandcloud org usageto accept optional--org-idand auto-detect when not provided. - Route org resolution through the shared
resolve_org_id(...)helper before calling the underlying CloudClient API methods. - Update README examples and add integration tests that assert the binary hits
/v1/organizationsthen the org-specific endpoint when org-id is omitted.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates org command examples to omit org id by default and documents --org-id for multi-org credentials. |
| crates/clickhousectl/tests/cli_request_shape_test.rs | Adds subprocess + wiremock coverage asserting org auto-detection request flow for prometheus/usage. |
| crates/clickhousectl/src/main.rs | Passes optional org id (as_deref()) through to the command handlers. |
| crates/clickhousectl/src/cloud/commands.rs | Resolves org_id via resolve_org_id for prometheus and usage before calling CloudClient methods. |
| crates/clickhousectl/src/cloud/cli.rs | Changes clap surface for org prometheus/org usage to optional --org-id and updates parsing + write-classification tests. |
Suppressed comments (1)
crates/clickhousectl/src/cloud/cli.rs:432
cloud org usagealso drops the old positional<org-id>in favor of only--org-id, which is a breaking change for existing callers. If backward compatibility matters, consider accepting the positional org id as an alias and preferring an explicit--org-idwhen both are provided (with a clear error on ambiguity).
/// Get organization usage/billing information
Usage {
/// Organization ID (auto-detected if not specified)
#[arg(long)]
org_id: Option<String>,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sdairs
force-pushed
the
codex/issue-337-org-autodetect
branch
from
August 3, 2026 18:42
b2660ed to
07fe835
Compare
sdairs
had a problem deploying
to
cloud-integration
August 3, 2026 18:42 — with
GitHub Actions
Failure
sdairs
had a problem deploying
to
cloud-integration
August 3, 2026 18:50 — with
GitHub Actions
Failure
sdairs
temporarily deployed
to
cloud-integration
August 3, 2026 18:57 — with
GitHub Actions
Inactive
sdairs
marked this pull request as ready for review
August 3, 2026 19:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--org-idoptional forcloud org prometheusandcloud org usageWhy
These two organization commands required a positional organization ID even though the rest of the cloud surface uses an optional
--org-idflag and auto-detects accounts with one organization.Impact
Users with one organization can now run
org prometheusororg usagewithout looking up and passing its ID. Users with access to multiple organizations can select one with--org-id. The existing required usage date flags are unchanged; date defaults remain a separate follow-up.Stack
This PR is stacked on #345 and should be reviewed as the delta from
codex/issue-340-local-use-error.Closes #337.
Validation
cargo fmt --all --checkcargo build -p clickhousectl --all-targetscargo test -p clickhousectlcargo clippy -p clickhousectl --all-targets -- -D warnings