Skip to content

Conversation

@Sypher845
Copy link
Contributor

Fixes #640

This pull request improves the label creation command in the Harbor CLI by enhancing error handling and adding validation for project-specific labels. The main changes focus on making the command more robust and user-friendly.

Validation for project-specific labels:

  • Added a check to ensure that when the label scope is set to project ('p'), a valid ProjectID must be provided. If not, a clear error message is returned.

Result
Screenshot from 2026-01-24 03-00-43

  • Added a check to verify that the specified project exists before creating a project-specific label, returning an error if the project does not exist.

Result
Screenshot from 2026-01-24 03-01-49

@codecov
Copy link

codecov bot commented Jan 23, 2026

Codecov Report

❌ Patch coverage is 44.44444% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 7.39%. Comparing base (60ad0bd) to head (7d08f42).
⚠️ Report is 82 commits behind head on main.

Files with missing lines Patch % Lines
cmd/harbor/root/labels/create.go 44.44% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             main    #641      +/-   ##
=========================================
- Coverage   10.99%   7.39%   -3.60%     
=========================================
  Files         173     260      +87     
  Lines        8671   12854    +4183     
=========================================
- Hits          953     951       -2     
- Misses       7612   11794    +4182     
- Partials      106     109       +3     

☔ 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.

Copy link
Collaborator

@bupd bupd left a comment

Choose a reason for hiding this comment

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

/lgtm @Sypher845 please add a test for the changes made. Thanks

@Sypher845
Copy link
Contributor Author

So sorry, I missed the notification for this! Working on it!!

Signed-off-by: Sypher845 <suyashpatil845@gmail.com>
Signed-off-by: Sypher845 <suyashpatil845@gmail.com>
@Sypher845 Sypher845 force-pushed the fix/validate-project-id-for-scope-p branch from 432a4c3 to 7d08f42 Compare February 1, 2026 20:14
@Sypher845
Copy link
Contributor Author

@bupd i have added the tests, please take a look.

@Sypher845 Sypher845 requested a review from bupd February 1, 2026 20:27
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.

harbor label create allows invalid project-scoped labels

2 participants