Skip to content

Add local server dotenv command#107

Merged
sdairs merged 4 commits intomainfrom
issue-90-server-dotenv
Apr 14, 2026
Merged

Add local server dotenv command#107
sdairs merged 4 commits intomainfrom
issue-90-server-dotenv

Conversation

@sdairs
Copy link
Copy Markdown
Collaborator

@sdairs sdairs commented Apr 10, 2026

Summary

  • Adds clickhousectl local server dotenv command that writes ClickHouse connection env vars (CLICKHOUSE_HOST, CLICKHOUSE_PORT, CLICKHOUSE_HTTP_PORT, CLICKHOUSE_USER, CLICKHOUSE_PASSWORD, CLICKHOUSE_DATABASE) to a .env file from a running server's details
  • Supports --name <server> to target a specific server (defaults to default) and --local to write to .env.local instead
  • If the .env file already exists, existing CLICKHOUSE_* vars are replaced in-place; missing vars are appended

Closes #90

Test plan

  • cargo build passes
  • cargo test passes (255 tests, 4 new for update_dotenv logic)
  • cargo clippy clean
  • Manual: start a server, run clickhousectl local server dotenv, verify .env contents
  • Manual: run again with different server, verify vars updated in-place
  • Manual: test --local flag writes to .env.local

🤖 Generated with Claude Code

…vars

Writes CLICKHOUSE_HOST, CLICKHOUSE_PORT, CLICKHOUSE_HTTP_PORT,
CLICKHOUSE_USER, CLICKHOUSE_PASSWORD, and CLICKHOUSE_DATABASE into
a .env file from a running server's connection details.

Supports --name to target a specific server and --local to write
to .env.local instead. If the file already exists, CLICKHOUSE_* vars
are replaced in-place rather than appending duplicates.

Closes #90

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sdairs sdairs requested a review from iskakaushik as a code owner April 10, 2026 16:55
@sdairs sdairs temporarily deployed to cloud-integration April 10, 2026 16:55 — with GitHub Actions Inactive
Two fixes to `local server dotenv`:

1. Only write vars we actually know from server metadata (host, ports).
   User, password, and database are no longer hard-coded — instead they
   are opt-in via --user, --password, --database flags. This prevents
   overwriting a working .env with incorrect defaults.

2. The dotenv updater now handles common variants: `export` prefix and
   whitespace around `=`. Previously `export CLICKHOUSE_HOST=x` would
   survive replacement and produce a duplicate line.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sdairs sdairs temporarily deployed to cloud-integration April 10, 2026 17:16 — with GitHub Actions Inactive
If the existing .env file uses `export CLICKHOUSE_X=val`, the
replacement now keeps the `export` prefix instead of silently
dropping it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sdairs sdairs temporarily deployed to cloud-integration April 10, 2026 19:59 — with GitHub Actions Inactive
Values like `my secret#123` are now written as `"my secret#123"`.
Embedded double quotes, backslashes, and newlines are escaped.
Plain alphanumeric values remain unquoted.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sdairs sdairs temporarily deployed to cloud-integration April 10, 2026 20:08 — with GitHub Actions Inactive
@sdairs sdairs merged commit 4e7659c into main Apr 14, 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.

Support inserting ClickHouse env vars into .env files

2 participants