Skip to content

refactor(robot): dynamically fetch and sort permissions with improved error handling#690

Open
qcserestipy wants to merge 1 commit intogoharbor:mainfrom
qcserestipy:fix/robot_perm_select
Open

refactor(robot): dynamically fetch and sort permissions with improved error handling#690
qcserestipy wants to merge 1 commit intogoharbor:mainfrom
qcserestipy:fix/robot_perm_select

Conversation

@qcserestipy
Copy link
Collaborator

@qcserestipy qcserestipy commented Feb 7, 2026

Overview

This PR does not change the functionality, but refactors the NewRobotPermissionsGrid in the robot permission selection. Before it was relying on hard coded actions and permissions for the table creation. This information is now retrieved directly from the harbor api as the permission spec might change in the future and hard coded parts break. Additionally, the go routine passes a customn struct that allows for more cleaner error handling than just os.Exit on failure

Changes

  • Fetch available permissions and actions from API instead of using hardcoded values
  • Sort resources and actions deterministically for reliable UI presentation
  • Introduce PermissionSelectResult struct for proper error propagation in channel
  • Support both 'project' and 'system' permission kinds
  • Remove os.Exit() calls in favor of channel-based error handling

… error handling

- Fetch available permissions and actions from API instead of using hardcoded values
- Sort resources and actions deterministically for reliable UI presentation
- Introduce PermissionSelectResult struct for proper error propagation in channel
- Support both 'project' and 'system' permission kinds
- Remove os.Exit() calls in favor of channel-based error handling

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
@codecov
Copy link

codecov bot commented Feb 7, 2026

Codecov Report

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

Files with missing lines Patch % Lines
pkg/views/robot/select/view.go 0.00% 48 Missing ⚠️
cmd/harbor/root/robot/create.go 0.00% 13 Missing ⚠️
cmd/harbor/root/robot/update.go 0.00% 12 Missing ⚠️
pkg/utils/utils.go 0.00% 5 Missing ⚠️
pkg/prompt/prompt.go 0.00% 4 Missing ⚠️
cmd/harbor/root/project/robot/create.go 0.00% 3 Missing ⚠️
cmd/harbor/root/project/robot/update.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             main    #690      +/-   ##
=========================================
- Coverage   10.99%   7.16%   -3.83%     
=========================================
  Files         173     260      +87     
  Lines        8671   12860    +4189     
=========================================
- Hits          953     922      -31     
- Misses       7612   11830    +4218     
- 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.

Copy link
Contributor

@NucleoFusion NucleoFusion left a comment

Choose a reason for hiding this comment

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

Looks pretty good!
We could also handle the api.GetPermissions() error here in my opinion

Comment on lines 322 to 323
response, _ := api.GetPermissions()
robotView.ListPermissions(response.Payload, kind, permissions)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we integrate the api.GetPermissions error to be returned here as well?

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.

2 participants