Skip to content

Extract cloud runtime dispatch and shared helpers from main.rs - #397

Merged
sdairs merged 1 commit into
issue-376-clickstack-models-finalizefrom
issue-383-cloud-runtime-boundary
Aug 13, 2026
Merged

Extract cloud runtime dispatch and shared helpers from main.rs#397
sdairs merged 1 commit into
issue-376-clickstack-models-finalizefrom
issue-383-cloud-runtime-boundary

Conversation

@sdairs

@sdairs sdairs commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Closes #383

Summary

  • Move cloud authentication, client construction, OAuth write guarding, dispatch, and CloudError adaptation into cloud::run.
  • Move managed Postgres dispatch into its domain module and remove cloud-domain imports from main.rs.
  • Keep agent detection/final JSON resolution at the top level and pass the resolved mode into the cloud runtime.
  • Add shared organization, enum/tag, and date/time parsing helpers to remove Postgres backward dependencies.

Tests

  • cargo fmt --all
  • cargo check --workspace --all-features
  • cargo test -p clickhousectl
  • cargo clippy -p clickhousectl --all-targets -- -D warnings

@sdairs
sdairs requested review from iskakaushik and rndD as code owners August 7, 2026 17:47
@sdairs
sdairs temporarily deployed to cloud-integration August 7, 2026 17:47 — with GitHub Actions Inactive
@sdairs sdairs changed the title Extract cloud runtime dispatch and shared helpers Extract cloud runtime dispatch and shared helpers from main.rs Aug 7, 2026
@sdairs
sdairs requested a lite review from Copilot August 8, 2026 08:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the ClickHouse Cloud command runtime in the clickhousectl CLI crate by extracting cloud authentication/client setup, OAuth write-guarding, command dispatch, and CloudError → top-level error adaptation out of main.rs and into crate::cloud::run, establishing a clearer runtime boundary for future domain moves.

Changes:

  • Delegate the top-level cloud command from main.rs to cloud::run, keeping JSON-mode resolution (flag + agent detection) at the top level.
  • Introduce cloud::run + cloud::dispatch in src/cloud/mod.rs, moving over auth/client construction, OAuth write rejection, and CloudError/exit-code preservation logic (with tests).
  • Add cloud::shared helpers (org resolution, enum/tag parsing, date/time parsers) and update Postgres + cloud CLI/commands to use them; move Postgres dispatch into cloud::postgres::run.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/clickhousectl/src/main.rs Removes inlined cloud runtime/dispatch and delegates Commands::Cloud to cloud::run after resolving JSON mode.
crates/clickhousectl/src/cloud/mod.rs Adds cloud::run + dispatch, plus error adaptation and tests, centralizing cloud runtime behavior outside main.rs.
crates/clickhousectl/src/cloud/shared.rs New internal shared helpers for org resolution, tag/enum parsing, and date/time clap parsers to avoid domain back-dependencies.
crates/clickhousectl/src/cloud/postgres.rs Moves Postgres dispatch into postgres::run and switches to shared helpers.
crates/clickhousectl/src/cloud/commands.rs Replaces local helper implementations with imports from cloud::shared.
crates/clickhousectl/src/cloud/cli.rs Switches date/time clap parsers to cloud::shared.
crates/clickhousectl/src/cli.rs Stops re-exporting cloud domain enums/args; keeps only what’s needed for top-level CLI assembly.
AGENTS.md Updates contributor docs to reflect the new cloud runtime/dispatch structure (cloud::run, cloud::dispatch, postgres::run).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@sdairs
sdairs force-pushed the issue-383-cloud-runtime-boundary branch from d0b8d4e to e53b87b Compare August 8, 2026 18:37
@sdairs
sdairs had a problem deploying to cloud-integration August 8, 2026 18:37 — with GitHub Actions Failure
@sdairs
sdairs had a problem deploying to cloud-integration August 8, 2026 18:45 — with GitHub Actions Failure
@sdairs
sdairs force-pushed the issue-383-cloud-runtime-boundary branch from e53b87b to 4772537 Compare August 13, 2026 11:37
@sdairs
sdairs had a problem deploying to cloud-integration August 13, 2026 11:38 — with GitHub Actions Failure
@sdairs
sdairs had a problem deploying to cloud-integration August 13, 2026 11:45 — with GitHub Actions Failure
@sdairs
sdairs force-pushed the issue-383-cloud-runtime-boundary branch from 4772537 to 5ffb52a Compare August 13, 2026 18:29

@iskakaushik iskakaushik left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sdairs
sdairs merged commit faf940a into main Aug 13, 2026
13 checks passed
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.

Extract cloud runtime dispatch and shared helpers from main.rs

3 participants