feat: distributed_cli (dsvc) — service CLI + Atlas schema output#74
Conversation
Add distributed_tooling::render_atlas_schema — a pure producer that wraps desired-state schema SQL (e.g. DistributedProjectManifest::sql_statements) into an AtlasSchema (db.atlasgo.io/v1alpha1) custom resource. DB URL via a Secret reference (GitOps) or inline (dev), optional devURL, SQL as a literal block scalar. The caller prints/redirects the result anywhere (stdout → any file or a separate schema repo); the crate deliberately does not pick a .gitops/ location. Implements [[tasks/atlas-operator-schema-gitops]] Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Warning Review limit reached
More reviews will be available in 10 minutes and 41 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (20)
📝 WalkthroughWalkthroughA new ChangesAtlas YAML generation module
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@distributed_tooling/src/atlas.rs`:
- Around line 51-69: Add Kubernetes name validation to render_atlas_schema:
implement a helper like validate_k8s_name(name: &str, field: &str) that trims
and enforces DNS subdomain rules (only lowercase a-z, digits, and '-' ; not
empty; not start or end with '-') and returns a ScaffoldError on violation, then
call validate_k8s_name for spec.name (and for spec.namespace when
trimmed_non_empty returns Some) at the start of render_atlas_schema to return
clear errors instead of emitting invalid YAML.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f601d2e9-4473-44f0-9293-aa4a26eb188f
📒 Files selected for processing (2)
distributed_tooling/src/atlas.rsdistributed_tooling/src/lib.rs
…t atlas Make Distributed's service tooling a single in-workspace crate that is both a binary (`dsvc`) and a library, eliminating cross-repo release coordination: - Fold the former `distributed_tooling` crate (pure scaffold + Atlas generation) into `distributed_cli` as internal `generate`/`atlas` modules; the public generation API is re-exported from the crate root. - Add the command surface (`cli` module): scaffold / describe / schema, ported from hops-cli's service adapter, with `run(&ServiceArgs)` as the dispatcher. - `dsvc schema --format atlas` renders an AtlasSchema resource to stdout (flag-configured: --name/--namespace/--db-secret/--db-secret-key/--db-url/ --dev-url); default --format sql is unchanged. - The library exposes `ServiceArgs` + `run` so another CLI (hops) can mount the commands under `hops service` and dispatch — re-exporting, not reimplementing, so a new flag here reaches hops on a plain `cargo update`. - Publish workflow: replace publish-tooling with publish-cli. distributed_tooling 1.5.0 stays on crates.io for the already-merged hops-cli until it migrates to depend on distributed_cli. Implements [[tasks/atlas-operator-schema-gitops]] Co-Authored-By: Claude Opus 4.8 <[email protected]>
Drive the real `dsvc` binary end-to-end: - cli_scaffold.rs: `dsvc scaffold` to a temp dir, assert the generated tree (fast; pure generation + filesystem; runs in normal `cargo test`). - cli_manifest.rs: `#[ignore]`d harness e2e — `dsvc describe`, `schema --dialect postgres`, and `schema --format atlas` against a committed `orders-service` fixture (a standalone crate with its own `[workspace]` and a `#[derive(ReadModel)]` registered in `distributed_manifest()`). Ignored by default because they compile the fixture via nested cargo. - integration-distributed-cli.yaml: reusable workflow running `cargo test -p distributed_cli -- --include-ignored`; referenced from the push-to-main pipeline and gating version-and-tag. Implements [[tasks/distributed-cli-integration-tests]] Co-Authored-By: Claude Opus 4.8 <[email protected]>
render_atlas_schema now rejects names that aren't RFC-1123 labels (lowercase letters, digits, hyphens; no leading/trailing hyphen) for both metadata.name and metadata.namespace, instead of only checking non-empty. This fails at generation with a clear message rather than emitting YAML the API server would reject — and guards against characters (newlines, colons, quotes) that would break the document itself. Addresses CodeRabbit review on PR #74. Implements [[tasks/atlas-operator-schema-gitops]] Co-Authored-By: Claude Opus 4.8 <[email protected]>
Summary
Make Distributed's service tooling a single in-workspace crate,
distributed_cli, that is both adsvcbinary and a library — removing the cross-repo release coordination that the hops-cli ↔ distributed_tooling split required.What changed
distributed_toolingintodistributed_clias internalgenerate/atlasmodules (still pure, no I/O); the generation API is re-exported from the crate root.climodule):scaffold/describe/schema, ported from hops-cli's service adapter, withpub fn run(&ServiceArgs)as the dispatcher anddsvcas the binary.dsvc schema --format atlasrenders anAtlasSchema(db.atlasgo.io/v1alpha1) resource to stdout, flag-configured (--name/--namespace/--db-secret/--db-secret-key/--db-url/--dev-url). Default--format sqlis unchanged. Nothing is written into.gitops/— redirect it wherever (e.g. a separate schema repo).ServiceArgs+runare public sohopscan mount the commands underhops serviceand dispatch — re-exporting, not reimplementing, so a new flag reaches hops on a plaincargo update.publish-tooling→publish-cli.Migration note
distributed_tooling1.5.0 stays on crates.io for the already-merged hops-cli until it migrates to depend ondistributed_cli(the optional, lightweight tie-in).Tests
26 tests pass (generation + Atlas renderer + CLI atlas-flag mapping).
dsvc --help/schema --helpverified. fmt + clippy clean; workspace resolves; rootdistributedunaffected.