feat: add --org flag to all relevant CLI commands#341
Open
devin-ai-integration[bot] wants to merge 3 commits intomainfrom
Open
feat: add --org flag to all relevant CLI commands#341devin-ai-integration[bot] wants to merge 3 commits intomainfrom
devin-ai-integration[bot] wants to merge 3 commits intomainfrom
Conversation
Add --org flag support to brev shell and brev open commands, following the existing pattern from brev start and brev ls. When provided, the --org flag overrides the active org for workspace resolution, preventing 'instance not found' errors when users haven't set their org context. Changes: - Add ResolveOrgFromFlag utility in pkg/cmd/util for shared org resolution - Add GetUserWorkspaceByNameOrIDErrInOrg for org-specific workspace lookup - Add ResolveWorkspaceOrNodeInOrg for org-specific workspace/node resolution - Add --org/-o flag with tab completion to shell command - Add --org/-o flag with tab completion to open command Co-Authored-By: Alec Fong <alecsanf@usc.edu>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #341 +/- ##
==========================================
+ Coverage 14.77% 17.63% +2.85%
==========================================
Files 127 140 +13
Lines 16977 18528 +1551
==========================================
+ Hits 2508 3267 +759
- Misses 14182 14902 +720
- Partials 287 359 +72
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add --org / -o flag to: stop, copy, exec, portforward, gpucreate, reset, recreate, ollama, workspacegroups commands. Also adds GetAnyWorkspaceByIDOrNameInOrgErr utility for org-specific workspace lookups and updates notebook.go caller for new RunPortforward signature. Co-Authored-By: Alec Fong <alecsanf@usc.edu>
Co-Authored-By: Alec Fong <alecsanf@usc.edu>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
--org/-oflag to all relevant CLI commands so users can override the active org for workspace resolution without needing to runbrev set {org}first. This prevents the common "instance not found" error when a user's active org doesn't match the org containing their workspace.Commands updated:
brev shell,brev open(initial scope)brev stop,brev copy,brev exec,brev port-forwardbrev create(gpucreate),brev reset,brev recreatebrev ollama,brev workspacegroupsNew shared utilities (
pkg/cmd/util/):ResolveOrgFromFlag— resolves org from flag or falls back to active orgGetUserWorkspaceByNameOrIDErrInOrg— workspace lookup in a specific orgResolveWorkspaceOrNodeInOrg— workspace-or-node lookup in a specific orgGetAnyWorkspaceByIDOrNameInOrgErr— any-workspace (admin) lookup in a specific orgAll commands with the flag also register tab completion via
GetOrgsNameCompletionHandler, exceptollama(hidden command) andworkspacegroups(stub command). Commands whose store interfaces embedcompletions.CompletionStorealready hadGetOrganizations;GPUCreateStore,OllamaStore, andWorkspaceGroupsStorehadGetOrganizationsadded explicitly.notebook.gowas updated to pass""(default org) for the newRunPortforwardparameter since it doesn't expose--orgitself.Updates since last revision
GetOrganizationsmethod toMockGPUCreateStoreingpucreate_test.goso the mock satisfies the updatedGPUCreateStoreinterface.Review & Testing Checklist for Human
brev stop <instance> --org <non-active-org>,brev shell <instance> --org <non-active-org>,brev create ... --org <non-active-org>to confirm correct workspace resolution across all updated commands.--organd confirm they still use the active org as before.FindExternalNodestill usesGetActiveOrganizationOrDefault()— when--orgis passed, workspace lookup uses the resolved org, but the external node fallback inResolveWorkspaceOrNodeInOrgstill searches the active org. Decide if this inconsistency is acceptable forshell,open,copy, andport-forward.stopadmin path —stopWorkspacefalls back toGetAnyWorkspaceByIDOrNameInOrgErrfor admins. Verify this works correctly when--orgis passed and the workspace belongs to another user in that org.gpucreateremoved nil guard —newCreateContextpreviously checkedif org == nilafterGetActiveOrganizationOrDefault(). NowResolveOrgFromFlagreturns an error instead of nil. Confirm the error message ("no orgs exist") is acceptable.Notes
ResolveOrgFromFlagduplicates the same logic asgetOrgForRunLsinls.go. A follow-up could consolidatels.goto use the shared utility.ResolveOrgFromFlag,GetUserWorkspaceByNameOrIDErrInOrg). These would benefit from coverage in a follow-up.ollamaandworkspacegroupsregister the--orgflag but do not register tab completion for it (unlike the other commands). This is intentional since they are hidden/stub commands.Link to Devin session: https://app.devin.ai/sessions/b9480e7c87b747e5b1d681faa65eddcb
Requested by: @theFong