Skip to content

fix(login): enforce mutual exclusivity of --password and --password-stdin flags#849

Merged
bupd merged 1 commit into
goharbor:mainfrom
gcharpe1604:fix/login-mutual-password-flags
May 7, 2026
Merged

fix(login): enforce mutual exclusivity of --password and --password-stdin flags#849
bupd merged 1 commit into
goharbor:mainfrom
gcharpe1604:fix/login-mutual-password-flags

Conversation

@gcharpe1604

Copy link
Copy Markdown
Contributor

Description

The harbor login command accepted both --password and --password-stdin simultaneously without any error. This caused silent ambiguous behavior where --password-stdin overwrote the -p value with no user-facing warning.

Type of Change

  • Bug fix

Changes

  • Added cmd.MarkFlagsMutuallyExclusive("password", "password-stdin") in LoginCommand() — uses Cobra's built-in constraint enforcement
  • Added -n as a short alias for --context-name to match convention of all other login flags
  • Added test case Test_Login_Failure_MutuallyExclusiveFlags to cover the validation

Testing

Verified locally:

@NucleoFusion NucleoFusion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!
Thanks for the contribution

@codecov

codecov Bot commented May 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 9.01%. Comparing base (60ad0bd) to head (b0ed752).
⚠️ Report is 146 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##             main    #849      +/-   ##
=========================================
- Coverage   10.99%   9.01%   -1.98%     
=========================================
  Files         173     272      +99     
  Lines        8671   13442    +4771     
=========================================
+ Hits          953    1212     +259     
- Misses       7612   12115    +4503     
- Partials      106     115       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…tdin flags

Signed-off-by: Govind Charpe <govind.charpe16@gmail.com>
@gcharpe1604 gcharpe1604 force-pushed the fix/login-mutual-password-flags branch from cc66a21 to b0ed752 Compare May 2, 2026 11:09
@qcserestipy qcserestipy self-requested a review May 3, 2026 13:10

@bupd bupd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@bupd bupd merged commit 1d19fb7 into goharbor:main May 7, 2026
6 of 8 checks passed
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.

fix(login): enforce mutual exclusivity of --password and --password-stdin

4 participants