feat(user): implement user update command - #1033
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1033 +/- ##
==========================================
- Coverage 10.99% 10.40% -0.59%
==========================================
Files 173 323 +150
Lines 8671 16239 +7568
==========================================
+ Hits 953 1689 +736
- Misses 7612 14416 +6804
- Partials 106 134 +28 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Implements a new harbor user update subcommand to update Harbor user profile fields (email, realname, comment) via either an interactive TUI form or a flag-driven workflow, aligning CLI capabilities with Harbor’s PUT /users/{user_id} endpoint.
Changes:
- Added interactive update form view for editing user profile fields.
- Added
harbor user updatecommand with ID/username resolution and flag-based updates. - Extended API user handler with update and user lookup helpers, plus basic command tests and command registration.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/views/user/update/view.go | Adds a TUI form for interactively editing user profile fields with validation. |
| pkg/api/user_handler.go | Adds API helper to update user profile and helper(s) to resolve/fetch users for the command. |
| cmd/harbor/root/user/update.go | Introduces the user update cobra command with interactive and non-interactive workflows. |
| cmd/harbor/root/user/update_test.go | Adds basic tests for command metadata and flag registration. |
| cmd/harbor/root/user/cmd.go | Registers the new update subcommand under the user command group. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
qcserestipy
left a comment
There was a problem hiding this comment.
Thank you for your contribution, please address the requested changes.
49fb8dc to
35b9e0a
Compare
qcserestipy
left a comment
There was a problem hiding this comment.
Please checkout the comments
This PR introduces the missing harbor user update command to support
updating a user's profile information (email, realname, and comment fields)
using the SDK's UpdateUserProfile and the REST API PUT /users/{user_id}.
It provides:
1. Interactive prompt workflow using huh form when no flags are supplied.
2. Non-interactive flag-based updates.
3. Proper user ID/name resolution and input verification.
4. Command unit tests.
Signed-off-by: shellyco-code <shellychahar57@gmail.com>
Signed-off-by: shellyco-code <shellychahar57@gmail.com>
Signed-off-by: shellyco-code <shellychahar57@gmail.com>
Signed-off-by: shellyco-code <shellychahar57@gmail.com>
Signed-off-by: shellyco-code <shellychahar57@gmail.com>
Signed-off-by: shellyco-code <shellychahar57@gmail.com>
ce82a3b to
c4da7b9
Compare
85eaabb to
63ee1d9
Compare
Signed-off-by: shellyco-code <shellychahar57@gmail.com>
63ee1d9 to
3e49872
Compare
Signed-off-by: shellyco-code <shellychahar57@gmail.com>
Signed-off-by: shellyco-code <shellychahar57@gmail.com>
Signed-off-by: shellyco-code <shellychahar57@gmail.com>
Signed-off-by: shellyco-code <shellychahar57@gmail.com>
Signed-off-by: shellyco-code <shellychahar57@gmail.com>
Signed-off-by: shellyco-code <shellychahar57@gmail.com>
Signed-off-by: shellyco-code <shellychahar57@gmail.com>
Signed-off-by: shellyco-code <shellychahar57@gmail.com>
Signed-off-by: shellyco-code <shellychahar57@gmail.com>
|
@shellyco-code Thank you for the changes, please fix merge conflicts first |
What type of PR is this?
/kind feature
What this PR does / why we need it:
The user command group currently supports create, delete, list, elevate, and password subcommands, but lacks an
updatecommand. In the Harbor REST API, thePUT /users/{user_id}endpoint allows administrators to update a user's email, realname, and comment fields.This PR implements the missing
harbor user updatecommand to support these user profile modifications.It features:
harbor user updateprompts the user to select a user from the visual list (usinghuhandbubbletea), prepopulates the form with existing user values (retrieved using the client), and allows interactive updates.harbor user update <username-or-id> --email "new@example.com" --realname "New Name"updates only the requested fields without displaying prompts, falling back to existing values for unspecified fields.403unauthorized responses to provide clean user feedback.cmd/harbor/root/user/update_test.go.Which issue(s) this PR fixes:
Fixes #966
Does this PR introduce a user-facing change?: