Finalizing Robots Account cli command#489
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #489 +/- ##
=========================================
- Coverage 10.99% 9.17% -1.83%
=========================================
Files 173 190 +17
Lines 8671 10447 +1776
=========================================
+ Hits 953 958 +5
- Misses 7612 9383 +1771
Partials 106 106 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
As discussed with @bupd, it could be also great to have a flag that can read permissions for a robot account from a yaml / json file and then skip the big selection screen. |
There was a problem hiding this comment.
Pull Request Overview
This PR finalizes the implementation of robot account management CLI commands, including creation, update, deletion, refresh, view, and listing of robot accounts. Key changes include:
- Addition of man and CLI documentation pages for all robot command sub-commands.
- Implementation of new CLI commands in the codebase under cmd/harbor/root/project/robot.
- Integration of user prompts and API calls for handling robot permissions and secret management.
Reviewed Changes
Copilot reviewed 34 out of 34 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| doc/man-docs/*.1 | New man pages for robot commands with minor spelling inconsistencies in header text. |
| doc/cli-docs/*.md | New CLI documentation for robot commands. |
| cmd/harbor/root/project/robot/*.go | New and updated CLI command implementations for robot account management. |
| cmd/harbor/root/project/cmd.go | Updated project command to include the new robot sub-command. |
Signed-off-by: bupd <bupdprasanth@gmail.com> Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
This commit adds delete and get project robot accounts cmds Signed-off-by: bupd <bupdprasanth@gmail.com> Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
…obot create; missing import in view.go; merge conflict in prompt.go Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: bupd <bupdprasanth@gmail.com> Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: bupd <bupdprasanth@gmail.com> Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: bupd <bupdprasanth@gmail.com> Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: bupd <bupdprasanth@gmail.com> Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
…ke table fashion. Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
- display robot name, status, permissions count, creation time, expiration, and description in a table - render a second table showing each resource and its allowed actions as ✓/✗ - reuse existing table layout code for the non-interactive view - maintain interactive table model in path for toggling permissions TODO: extract the table Model into its own package and share between create and view Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
- display robot name, status, permissions count, creation time, expiration, and description in a table - render a second table showing each resource and its allowed actions as ✓/✗ - reuse existing table layout code for the non-interactive view - maintain interactive table model in create path for toggling permissions TODO: extract the table Model into its own package and share between create and view Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
This commit adds several improvements to robot account creation: Implements a general table grid view component for permission selection with interactive cell toggling and proper navigation Adds functionality to load robot account configurations from YAML files with support for wildcard actions and grouped resources Refactors the robot account creation flow to prioritize config files and only show the form when necessary Adds validation for project existence and robot name uniqueness when loading from config files Includes an example configuration file at robot-config.yaml demonstrating the YAML format with various permission patterns This enhancement improves automation capabilities by allowing robot accounts to be defined as code while maintaining the interactive UI when needed. Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
… list unavailable commands Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
…m permissions that are available in the harbor api Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
…le directly Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
This change allows robot configuration to be loaded from both YAML and JSON files. The system now automatically detects file type based on extension and processes accordingly, while maintaining the same validation and permission handling logic. Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Enhance the Long help text for all robot-related commands with detailed descriptions, consistent formatting, and comprehensive examples. This improves user experience by providing clearer instructions on how to use robot account management commands. Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
|
@bupd This branch is ready for review now. Please feel free to try stuff out. I am looking forward to your feedback and thank you for your time to review! |
…olumn toggle work 'vim-style' Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Updated TableGrid ModelI updated the table grid model to also allow for toggling columns. Columns and rows can be toggled in a vim style with Screen.Recording.2025-06-12.at.18.14.22.mov |
bupd
left a comment
There was a problem hiding this comment.
Here is my feedback after testing.
- Currently I need to press
Ctrl + jtwo times to select a row. and same to unselect a row. Ctrl + jis the only thing that works now.
ctrl+kand column selection usingctrl+h / ldoesn't work
- Wrong Error Message on trying to create a Robot Account with the same name.
❯ ./bin/harbor-dev project robot create --project demo --name kumaruu --description power --duration -1
Error: failed to create robot: bad request permission: robot-account:create
|
Hi @bupd, thank you for your feedback! I am a little bit surprised by the CLI behavior you describe in 1. and 2. I am wondering right now what might be the reason for this. Did you pull the latest version of this branch? In my environment I am on MacOs and I assume you are on Linux? Maybe that could be a reason? Maybe we can discuss this in a call. Concerning 3. I will make sure to improve that. Thanks again for your help—let me know the details above, and I’ll get these fixed ASAP! |
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
|
@bupd Concerning point 3.: There was actually still a small bug in the permissions grid, because in the Harbor swagger api the Robots resource is called This is because in v2.10.0 the go-client does not support return code 409 in the swagger definition. Also in v2.13.1 of the go-client it won't be their. Is this a feature request that we have to open in the harbor repository? |
yeah feel free to do so. To fix this we can add a validation like in the UI to check if the robot account name is already created using the above as a validation before actually do the POST request would solve this issue. Thanks |
… same already exists. To do so the robot handler now has a function that can check for existance of a robot by name. It searches for all robots in the target project and filter whether the to be created robot's name already exists there. To that end it queries the project name and robot account name prefix from the instance configuration. This is necessary since the q=name=<targetName> returns ambiguous results Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
|
@bupd Thank you for your feedback!
This approach is needed since there is an issue whith Harbor API's name query filter |
bupd
left a comment
There was a problem hiding this comment.
lgtm
changes requested here would be created in next PR
There was a problem hiding this comment.
❯ ./bin/harbor-dev project robot list test -o yamlss
~/code/OSS/harbor-cli-pr robots
❯ ./bin/harbor-dev project list -o jslns
Error: unable to output in the specified 'jslns' format
should not allow other formats.
There was a problem hiding this comment.
expiration should be a validation field. with default value being -1 and not 0.
There was a problem hiding this comment.
toggle j for on and k for off. in the permission selection.
…ts to PR #489) (#503) * feat(ui): improve table grid controls and form validation - refactor(tablegrid): change toggle controls to explicit on/off actions - feat(tablegrid): add table-wide toggle shortcuts (ctrl+a, ctrl+d) - fix(robot): improve validation for robot creation expiration time - fix(cmd): convert Run to RunE for proper error handling in robot list - docs(ui): update keyboard shortcut documentation in footer text Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Added changes to satisfy linter Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> * Added readme.md for robot config file Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> --------- Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com> Co-authored-by: Prasanth Baskar <bupdprasanth@gmail.com>
Fixes #100
Objective:
Tasks
Add CLI Commands for Robot Account Management on System Level:
Finalizing work of @bupd on CLI Commands for Robot Account Management on Project Level.
Rationale
Implementing secure and efficient robot account management in the CLI is crucial for enabling automated operations and replication, enhancing overall project security and functionality.
Changes
I want to suggest a change in the way how permissions can be selected for the robot account creation. I used a
huhForm to emulate a grid like experience we also have in the harbor UI. I would like to use it as a discussion basis:Screen.Recording.2025-06-06.at.20.09.48.mov
Robots can be created from yaml or json file (I added examples in the examples dir):
Screen.Recording.2025-06-08.at.16.20.16.mov
The secret creation screen can be skipped and directly exported to json file like in the UI:
Screen.Recording.2025-06-09.at.12.16.35.mov
The robot view command can also present the permissions in a table like this similar to the UI:
Screen.Recording.2025-06-09.at.11.15.28.mov
Emojis and empty spaces for unavailable permissions is similar to create experience