Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

Add --org flag to login command for organization validation

Summary

Added a --org/-o flag to the brev login command that allows users to specify which organization to use during login. The flag validates that the organization exists (without creating it) and sets it as the default organization after successful authentication.

Key Changes:

  • Added SetDefaultOrganization method to LoginStore interface
  • Added --org/-o flag to login command with validation logic
  • Modified getOrCreateOrg to handle organization validation when flag is provided
  • Maintains backward compatibility - existing behavior preserved when flag not used
  • Follows existing validation patterns from ls command

Review & Testing Checklist for Human

⚠️ 4 items - moderate risk due to interface changes and untested validation logic

  • Test --org flag with existing organization name - verify login succeeds and org is set as default
  • Test --org flag with non-existent organization name - verify clear error message is shown
  • Test login without --org flag - verify existing behavior still works (gets active org or creates default)
  • Verify organization is actually set as default - after login with --org, check that subsequent commands use the specified org

Recommended Test Plan

  1. Log out completely: brev logout
  2. Test with valid org: brev login --org <existing-org-name>
  3. Verify org is active: brev ls orgs (should show specified org as active)
  4. Test with invalid org: brev login --org nonexistent-org (should fail with clear error)
  5. Test normal login: brev login (should work as before)

Notes

  • Implementation follows validation patterns from ls command's org handling
  • Interface change adds SetDefaultOrganization method - ensure all LoginStore implementations support this
  • Error messages use same format as existing org validation in getOrgForRunLs

Link to Devin run: https://app.devin.ai/sessions/2270f8421e424040b0557b3385c34bb2
Requested by: @theFong

- Added SetDefaultOrganization to LoginStore interface
- Added --org/-o flag to login command that validates org exists
- Modified getOrCreateOrg to accept orgFlag parameter and validate
- Returns error if org doesn't exist or multiple matches found
- Maintains backward compatibility when flag is not provided
- Follows existing pattern from ls command org validation

Co-Authored-By: Alec Fong <[email protected]>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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