Skip to content

Add cloud service client command#63

Merged
sdairs merged 8 commits intomainfrom
issue-56-cloud-service-client
Mar 30, 2026
Merged

Add cloud service client command#63
sdairs merged 8 commits intomainfrom
issue-56-cloud-service-client

Conversation

@sdairs
Copy link
Copy Markdown
Collaborator

@sdairs sdairs commented Mar 28, 2026

Summary

  • Adds cloud service client subcommand to connect to ClickHouse Cloud services via the native clickhouse-client
  • Resolves service by --name (service name) or --id (service ID)
  • Auto-downloads the matching ClickHouse version for the client binary, reusing existing local install logic
  • --allow-mismatched-client-version flag to use the local default version instead (with a warning)
  • Password resolution: --password flag > CLICKHOUSE_PASSWORD env var > interactive TTY prompt > error
  • Hidden --generate-password flag that resets the service password via API and uses it (agent-friendly escape hatch)
  • Mirrors local client flags: --query, --queries-file, --user, and -- passthrough args

Usage

# Connect by service name
clickhousectl cloud service client --name my-service --password secret

# Connect by service ID with a query
clickhousectl cloud service client --id abc123 -q "SELECT 1" --password secret

# Use env var for password (agent-friendly)
CLICKHOUSE_PASSWORD=secret clickhousectl cloud service client --name my-service -q "SELECT count() FROM system.tables"

# Use local client version instead of auto-downloading
clickhousectl cloud service client --name my-service --allow-mismatched-client-version

Test plan

  • Verify cloud service client --help shows expected flags
  • Verify --generate-password is hidden from help but accepted
  • Test with a live cloud service: --name lookup, --id lookup
  • Test password resolution: flag, env var, TTY prompt
  • Test auto-install of matching version
  • Test --allow-mismatched-client-version with a local default set
  • All existing tests pass (156 unit + 2 integration)

Closes #56

🤖 Generated with Claude Code

Adds a new subcommand that connects to a ClickHouse Cloud service
using the native clickhouse-client. Resolves service by --name or --id,
auto-downloads the matching ClickHouse version, and supports multiple
password methods (flag, env var, TTY prompt, or hidden --generate-password
that resets via API).

Closes #56

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sdairs sdairs requested a review from iskakaushik as a code owner March 28, 2026 17:48
@sdairs sdairs temporarily deployed to cloud-integration March 28, 2026 17:48 — with GitHub Actions Inactive
Remove redundant subcommand listings and flag descriptions from
CONTEXT FOR AGENTS sections — focus on non-obvious guidance only.
Also remove hidden --generate-password from agent context.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sdairs sdairs temporarily deployed to cloud-integration March 28, 2026 17:57 — with GitHub Actions Inactive
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sdairs sdairs temporarily deployed to cloud-integration March 28, 2026 18:09 — with GitHub Actions Inactive
Tests query-by-id and query-by-name against a live cloud service
using the password from service creation. Runs in the Capability
Checks phase of the existing CRUD lifecycle test.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sdairs sdairs had a problem deploying to cloud-integration March 28, 2026 18:25 — with GitHub Actions Failure
- Add --password to the redact list in redact_command so passwords
  never appear in CI output
- Add integration test for --generate-password (resets password via
  API and uses it to query)
- Add unit test verifying password redaction works

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sdairs sdairs had a problem deploying to cloud-integration March 28, 2026 18:52 — with GitHub Actions Failure
- Open IP access (0.0.0.0/0) before client tests so CI runner can
  connect, remove it after
- Change install_version progress messages from println to eprintln
  so they don't contaminate clickhouse-client stdout output

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sdairs sdairs had a problem deploying to cloud-integration March 29, 2026 10:44 — with GitHub Actions Failure
Resolve the version spec to an exact version before checking if it's
installed. Previously "25.12" would miss the existing "25.12.9.61"
directory, causing install_version to fail on the second call.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sdairs sdairs had a problem deploying to cloud-integration March 29, 2026 10:54 — with GitHub Actions Failure
Wait in case of any delay in password propagation after an API reset.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sdairs sdairs merged commit 1b6d6ac into main Mar 30, 2026
1 check 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.

Improve UX to query cloud services without using local client cmd

2 participants