Skip to content

refactor(cli): split cloud postgres into a module directory (#1157) - #1170

Open
sdairs wants to merge 4 commits into
claude/1157-split-cloud-servicesfrom
claude/1157-split-cloud-postgres
Open

sdairs wants to merge 4 commits into
claude/1157-split-cloud-servicesfrom
claude/1157-split-cloud-postgres

Conversation

@sdairs

@sdairs sdairs commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Part of #1157 (2 of 5: postgres). Stacked on #1168.

Summary

This splits src/cloud/postgres.rs into src/cloud/postgres/, following the pattern #1168 set. Behaviour is unchanged.

File Lines (tests) Contents
mod.rs 462 PERMISSIONS, run, re-exports
cli.rs 2363 (58) clap definitions
client.rs 456 impl CloudClient wrappers (the two blocks are merged into one)
lifecycle.rs 1410 (28) list/get/create/update/delete/reset-password/restart, certs, filter and access-rule parsers
config.rs 558 (11) runtime config and its file loaders
query.rs 327 (6)
observability.rs 1012 (14) logs, metrics, slow-queries, prometheus, backups
topology.rs 452 (5) read-replica, restore, promote, switchover

Commits

  1. Pure git mv to postgres/mod.rs, at 100% similarity.
  2. Moves only. I checked the line multisets. The only differences are mod/use lines, visibility, three rustfmt signature rewraps, the merged impl CloudClient { line, and four section banners dropped because they no longer apply (Helpers, Option structs, Handlers, Tests).
  3. .git-blame-ignore-revs entry. The SHA needs updating on rebase.
  4. Docs: the add-cli-command Cloud reference now points at postgres/ and postgres/client.rs.

Notes

  • list_postgres_services is now pub(in crate::cloud), because shared.rs uses it. The slow-query, logs and backup query structs and their fields are pub(super).
  • The access_rule test helper is shared by three test modules through pub(in crate::cloud::postgres), so it isn't duplicated.
  • A #[cfg(doc)] use keeps one intra-doc link resolving.

Tests

  • Counts match before and after: 2419 passed, 7 ignored. Test names match once module paths are normalised.
  • fmt, both clippy configurations, the --no-default-features check, the Python classifier tests and git diff --check all pass.
  • The known local_postgres_client_input_test flake failed once and passed on rerun.

Merge with a merge commit, not a squash. The .git-blame-ignore-revs entry names this PR's move commit. A squash merge would leave it pointing at a commit that isn't on main, and git would silently ignore it.

🤖 Generated with Claude Code


Note

Low Risk
Pure module reorganization with unchanged test counts and no intentional logic changes; merge should use a merge commit so the blame-ignore SHA stays valid.

Overview
Refactors the monolithic cloud postgres implementation into src/cloud/postgres/, matching the layout introduced for cloud services in the same effort (#1157). Behaviour and CLI surface stay the same; this is a move/split only.

The former single file is broken out by concern: cli.rs (clap + parse tests), client.rs (merged CloudClient API wrappers), lifecycle.rs (CRUD, certs, passwords, filters/access rules), config.rs, plus query.rs, observability.rs, and topology.rs for query, metrics/logs/backups, and replica/restore/role commands. mod.rs keeps PERMISSIONS, dispatch via run(), and re-exports.

Minor visibility adjustments support the split (e.g. list_postgres_services is pub(in crate::cloud) for name resolution in shared.rs). Agent docs now reference postgres/ and convert_postgres_by_id_result in postgres/client.rs, and .git-blame-ignore-revs records the bulk-move commit for blame.

Reviewed by Cursor Bugbot for commit 87f409b. Bugbot is set up for automated code reviews on this repo. Configure here.

sdairs and others added 4 commits October 30, 2026 16:38
Move `cloud/postgres.rs` to `cloud/postgres/mod.rs` unchanged, so blame
follows the file into the new layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
)

Move the `postgres` command code out of `cloud/postgres/mod.rs` into one
file per command family, each with the tests for its code:

- `cli.rs`: clap definitions and parse tests
- `client.rs`: `CloudClient` wrappers, in one `impl` block
- `lifecycle.rs`: list, get, create, update, delete, certs,
  reset-password and restart, with the list filter and access-rule parsers
- `config.rs`: runtime config get, replace and patch, and the config
  file loaders
- `query.rs`: `postgres query`
- `observability.rs`: logs, metrics, slow queries, prometheus and backups
- `topology.rs`: read replicas, restore, promote and switchover

`mod.rs` keeps `PERMISSIONS`, the `run` dispatch and re-exports of the
command enums. Only visibility and imports change, and the section
banners that described the old single-file layout are dropped; no
behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
)

The add-cli-command Cloud reference named `src/cloud/postgres.rs` as a
pattern to copy and as the home of `convert_postgres_by_id_result`. Point
it at `src/cloud/postgres/` and `postgres/client.rs`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sdairs
sdairs force-pushed the claude/1157-split-cloud-postgres branch from 7b7ea44 to 87f409b Compare October 30, 2026 17:27
@sdairs
sdairs added this pull request to stack #1153 October 30, 2026 17:28

This branch has not been deployed

No deployments
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.

1 participant