Skip to content

fix: project view --id flag not working#639

Open
Sypher845 wants to merge 2 commits intogoharbor:mainfrom
Sypher845:fix/project-view-by-id
Open

fix: project view --id flag not working#639
Sypher845 wants to merge 2 commits intogoharbor:mainfrom
Sypher845:fix/project-view-by-id

Conversation

@Sypher845
Copy link
Contributor

Fixes #638

image

This pull request updates how project existence checks are performed across several project-related commands, allowing the checks to distinguish between project names and project IDs. The main change is to the CheckProject function, which now accepts a flag to specify whether to check by project name or ID, and all relevant commands have been updated to use this new parameter.

API changes:

  • Updated the CheckProject function in project_handler.go to accept a useProjectID boolean parameter, enabling checks by either project name or project ID. The function now uses GetProject when checking by ID and falls back to the original method when checking by name.

Command updates:

  • Updated the logs, view, member create, and member delete commands to call CheckProject with the appropriate isID flag, ensuring that project existence checks are accurate based on whether a name or ID is provided.
  • Modified the view command to also pass the isID flag to GetProject after the existence check, ensuring the project is retrieved using the correct identifier type.

@codecov
Copy link

codecov bot commented Jan 23, 2026

Codecov Report

❌ Patch coverage is 0% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 7.18%. Comparing base (60ad0bd) to head (4428927).
⚠️ Report is 83 commits behind head on main.

Files with missing lines Patch % Lines
cmd/harbor/root/project/member/create.go 0.00% 5 Missing ⚠️
cmd/harbor/root/project/member/delete.go 0.00% 5 Missing ⚠️
pkg/utils/error.go 0.00% 5 Missing ⚠️
cmd/harbor/root/project/logs.go 0.00% 4 Missing ⚠️
cmd/harbor/root/project/view.go 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             main    #639      +/-   ##
=========================================
- Coverage   10.99%   7.18%   -3.81%     
=========================================
  Files         173     260      +87     
  Lines        8671   12832    +4161     
=========================================
- Hits          953     922      -31     
- Misses       7612   11802    +4190     
- Partials      106     108       +2     

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

@Sypher845
Copy link
Contributor Author

@bupd @NucleoFusion please review.

@qcserestipy qcserestipy self-requested a review February 6, 2026 18:37
Copy link
Collaborator

@qcserestipy qcserestipy left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution! I added a few comments. It would make the code simpler by removing the CheckProject function and replace the logic where it is used with GetProject.

Signed-off-by: Sypher845 <suyashpatil845@gmail.com>
Signed-off-by: Sypher845 <suyashpatil845@gmail.com>
@Sypher845 Sypher845 force-pushed the fix/project-view-by-id branch from bad54ba to 4428927 Compare February 7, 2026 11:31
@Sypher845
Copy link
Contributor Author

@qcserestipy
I found one thing , in pkg/utils/error.go the ParseHarborErroCode can only check for error of format [404].
But the project, err = api.GetProject(projectName, isID) in this the err has a format of (status 404), the current ParseHarborErrorCode cannot parse this format, so i added the format checking also.
please take a look

@Sypher845 Sypher845 requested a review from qcserestipy February 7, 2026 11:35
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 project view --id flag is defined but not implemented

2 participants