Skip to content

Conversation

afeefuddin
Copy link
Contributor

@afeefuddin afeefuddin commented May 18, 2025

Improve and fix the scope flag for labels.

1. harbor-cli label list

  • List global labels when scope is not passed
  • List project labels when scope and projectId is passed
Screencast.from.2025-05-18.23-57-18.mp4

2. harbor-cli label create

  • Asks for project Id when scope=project but project id is not passed in flags
  • Creates a label directly when projectId flag is passed
Screencast.from.2025-05-19.00-00-24.mp4

3. harbor-cli label delete

  • Shows global labels list to select from when scope flag is not set
  • Show project label list to delete
Screencast.from.2025-05-19.00-02-36.mp4

4. harbor-cli label update

  • Shows global labels list to select from when the scope flag is not set
  • Show project label list to update
Screencast.from.2025-05-19.00-03-58.mp4

@afeefuddin afeefuddin force-pushed the add_scope_to_label branch 2 times, most recently from 5277c5f to bc779e8 Compare May 18, 2025 18:00
@afeefuddin afeefuddin force-pushed the add_scope_to_label branch from 7714c28 to 1a765c8 Compare May 18, 2025 18:42
@afeefuddin afeefuddin marked this pull request as ready for review May 18, 2025 18:46
Signed-off-by: afeefuddin <[email protected]>
Signed-off-by: afeefuddin <[email protected]>
@Vad1mo Vad1mo requested a review from Copilot June 5, 2025 06:33
Copilot

This comment was marked as outdated.

@Vad1mo Vad1mo requested a review from Copilot June 17, 2025 13:20
@Vad1mo Vad1mo assigned bupd and unassigned bupd Jun 17, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves label commands by refining how scope options and project IDs are handled across listing, creating, updating, and deleting labels. Key changes include updating function signatures to return errors instead of using channels, propagating the project ID through the API calls, and aligning CLI documentation and flag names with the new behavior.

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/views/project/select/view.go Adds a new function to select a project with its ID.
pkg/views/label/select/view.go Refactors label selection to return the chosen label ID with error handling.
pkg/views/label/create/view.go Adds a scope select input and validation for creating a label.
pkg/prompt/prompt.go Introduces functions to prompt for project and label IDs with improved error handling.
pkg/api/label_handler.go Passes the project ID for label creation and updates the signature for label lookups.
doc/man-docs/man1/harbor-label-*.1 Updates the CLI man pages to reflect the new flag naming for project ID.
doc/cli-docs/harbor-label-*.md Revises the CLI documentation examples to match the updated flag names.
cmd/harbor/root/labels/update.go Changes error handling to return errors and propagates the project ID in updates.
cmd/harbor/root/labels/list.go Renames the project ID flag for consistency.
cmd/harbor/root/labels/delete.go Adopts RunE for better error propagation and adjusts flag usage.
cmd/harbor/root/labels/create.go Passes flags into the label creation view and prompts for project ID as needed.
Comments suppressed due to low confidence (3)

cmd/harbor/root/labels/update.go:14

  • Consider renaming 'UpdateLableCommand' to 'UpdateLabelCommand' to fix the typo and improve clarity.
package labels

pkg/api/label_handler.go:125

  • If no label is found in GetLabelIdByName, returning 0 with err (which may be nil) could be misleading. Consider returning a clear error, such as 'label not found', to indicate the absence of a matching label.
		return 0, err

cmd/harbor/root/labels/delete.go:45

  • [nitpick] Update the error message to clearly indicate that the failure occurred during retrieval of the label id for deletion, for example: 'failed to retrieve label id for deletion: %v'.
				return fmt.Errorf("failed to get label id: %v", err)

@bupd bupd added help wanted Extra attention is needed Changes Requesed feedback that must be addressed before merging. labels Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changes Requesed feedback that must be addressed before merging. help wanted Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants