feat(cli): add export command to generate desired-state YAML from current state#1731
feat(cli): add export command to generate desired-state YAML from current state#1731rohilsurana wants to merge 4 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds export support to the reconcile framework, implements platform user export, and wires a new ChangesReconcile export feature
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
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
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 75607dba-a629-489d-b90a-5de555cb5f68
📒 Files selected for processing (5)
cmd/reconcile.gointernal/reconcile/platformuser_reconciler.gointernal/reconcile/platformuser_reconciler_test.gointernal/reconcile/reconcile.gointernal/reconcile/reconcile_test.go
Coverage Report for CI Build 28667590558Coverage increased (+0.09%) to 44.957%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
2ca9edd to
d553b7f
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 025c0faa-f5bc-4b12-bf33-7bcc3ee2fbaa
📒 Files selected for processing (7)
cmd/apply.gocmd/get.gocmd/root.gointernal/reconcile/platformuser_reconciler.gointernal/reconcile/platformuser_reconciler_test.gointernal/reconcile/reconcile.gointernal/reconcile/reconcile_test.go
✅ Files skipped from review due to trivial changes (1)
- internal/reconcile/reconcile.go
🚧 Files skipped from review as they are similar to previous changes (3)
- internal/reconcile/platformuser_reconciler.go
- internal/reconcile/platformuser_reconciler_test.go
- internal/reconcile/reconcile_test.go
d553b7f to
987ae62
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
cmd/export.go (1)
51-56: 🔒 Security & Privacy | 🟡 Minor | ⚡ Quick winNarrow output file permissions for exported PII.
The exported document contains per-principal emails; writing with
0o644leaves it world-readable. Matches an already-flagged concern on a prior commit of this file.🔒 Proposed fix
- return os.WriteFile(output, out, 0o644) + return os.WriteFile(output, out, 0o600)
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4ef1ccea-dab3-45ac-8fb9-8f03784960e8
📒 Files selected for processing (7)
cmd/export.gocmd/reconcile.gocmd/root.gointernal/reconcile/platformuser_reconciler.gointernal/reconcile/platformuser_reconciler_test.gointernal/reconcile/reconcile.gointernal/reconcile/reconcile_test.go
🚧 Files skipped from review as they are similar to previous changes (4)
- internal/reconcile/reconcile_test.go
- internal/reconcile/reconcile.go
- internal/reconcile/platformuser_reconciler.go
- internal/reconcile/platformuser_reconciler_test.go
987ae62 to
12fc9a5
Compare
…xport in CLI reference
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cmd/export.go (1)
47-50: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueSkip the byte→string conversion.
string(out)allocates a copy just to hand it back toFprint. Writing the bytes directly avoids the extra allocation.♻️ Proposed simplification
- // cobra's cmd.Print falls back to stderr; the document must go to - // stdout so redirecting to a file works. - _, err = fmt.Fprint(cmd.OutOrStdout(), string(out)) - return err + // cobra's cmd.Print falls back to stderr; the document must go to + // stdout so redirecting to a file works. + _, err = cmd.OutOrStdout().Write(out) + return err
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a3d55fcb-3ab0-46c1-9eb0-a4adceb02a73
📒 Files selected for processing (9)
cmd/export.gocmd/export_test.gocmd/reconcile.gocmd/root.godocs/content/docs/reference/cli.mdxinternal/reconcile/platformuser_reconciler.gointernal/reconcile/platformuser_reconciler_test.gointernal/reconcile/reconcile.gointernal/reconcile/reconcile_test.go
🚧 Files skipped from review as they are similar to previous changes (4)
- internal/reconcile/reconcile_test.go
- internal/reconcile/platformuser_reconciler_test.go
- internal/reconcile/platformuser_reconciler.go
- internal/reconcile/reconcile.go
What
Adds
frontier export <kind>, a top-level sibling offrontier reconcile. It reads the current state of one kind from the server through the admin API and prints it as a desired-state YAML document, the same formatreconcilereads. Output goes to stdout only — redirect it to save a file. YAML is the only format.The
reconcilecommand is unchanged. The kind argument is case-insensitive and accepts a plural, soplatformusersfindsPlatformUser. An unknown kind lists the available ones.Both
reconcileandexportare now documented in the CLI reference (reconcilewas missing from it).Why
When an environment adopts the reconcile flow, its first desired-state file must match what already exists on the server. If it does not, the first apply makes unwanted changes. Writing that file by hand from list APIs is slow and easy to get wrong.
How
Exporterinterface next toReconcilerininternal/reconcile. A kind that implements it can be exported. Kinds that do not implement it return a clear error.PlatformUserimplements it: one entry per principal and relation — a user or service user holding both admin and member exports as two entries. Users are referenced by email when they have one, service users by id. The bootstrap service account is skipped, the same as in reconcile.spec: [], which reconcile accepts as an intentional empty list.reconcileandexport.Guarantees covered by tests
reconcile --dry-runreports no changes, including principals that hold both relations.