fix(cli): support json profile output#3448
Conversation
Signed-off-by: jakedoublev <jake.vanvorhis@virtru.com>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR extends the otdfctl CLI's profile subcommands to emit structured JSON output alongside human-readable formatting. It introduces default printer state management, refactors error exit handlers to use the new infrastructure, implements JSON payload generation for profile list and get operations, and adds comprehensive E2E test coverage. ChangesJSON Output for Profile Commands
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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 |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the otdfctl CLI by introducing structured JSON output for profile-related commands. By enabling JSON support for both successful data retrieval and error messages, the CLI becomes more suitable for programmatic consumption and integration into automated workflows. The changes include updates to the printer logic, command implementations, and comprehensive end-to-end tests to ensure reliability. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. The CLI output is now clean, With JSON for every machine. No more parsing the text, Automation is next, And the data is clearly seen. Footnotes
|
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
There was a problem hiding this comment.
Code Review
This pull request implements JSON output support for the profile list and profile get commands. It introduces structured output models, updates the CLI's exit and printing logic to handle JSON formatting based on a global state, and adds comprehensive E2E tests. Review feedback suggests optimizing logic by reusing evaluated boolean variables and adhering to CLI conventions by directing error output to os.Stderr.
Signed-off-by: jakedoublev <jake.vanvorhis@virtru.com>
Signed-off-by: jakedoublev <jake.vanvorhis@virtru.com>
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
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 `@otdfctl/pkg/cli/printer.go`:
- Around line 35-39: The method setJSON on Printer should not mutate the
package-level defaultJSONOutput global; remove the defaultJSONOutput.Store(json)
call from Printer.setJSON and instead set defaultJSONOutput only when creating a
new Printer (e.g., in newPrinter) so the global default is established at
construction time and not toggled by later SetJSONOutput(false) calls; update
newPrinter to honor an initial json flag and call defaultJSONOutput.Store(json)
there, leaving Printer.setJSON to only adjust the receiver's p.json and
p.enabled fields.
🪄 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: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 99895017-3d3a-4322-896c-c6d4b17096bf
📒 Files selected for processing (4)
otdfctl/cmd/profile.gootdfctl/e2e/profile.batsotdfctl/pkg/cli/errors.gootdfctl/pkg/cli/printer.go
Signed-off-by: jakedoublev <jake.vanvorhis@virtru.com>
Signed-off-by: jakedoublev <jake.vanvorhis@virtru.com>
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
Signed-off-by: jakedoublev <jake.vanvorhis@virtru.com>
Signed-off-by: jakedoublev <jake.vanvorhis@virtru.com>
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
|
Summary
Inspired by: https://trevinsays.com/p/10-principles-for-agent-native-clis
Summary by CodeRabbit
New Features
profile listandprofile getcommands via--jsonflagTests