feat(user): add fuzzy, match, range flags for commands#682
feat(user): add fuzzy, match, range flags for commands#682Mujib-Ahasan wants to merge 8 commits into
Conversation
|
Hello @NucleoFusion, this is yet to be tested, but I am really confused to find the keys to be used in list subcommands. Changes have been made for |
|
@Mujib-Ahasan the keys are the fields/keys in the JSON object they return. They are available on the demo.goharbor.io swagger api |
|
Great, Thank you @NucleoFusion! |
|
@NucleoFusion , PTAL at these changes. after that I will do some tests against my local setup. |
All these are supported via the |
(only for list subcommand) @NucleoFusion PTAL. |
|
Have you done all those? In the checklist that have CLI present? |
|
I did only for those which has --query flag (--query in the bracket in my prev comment) . I have not worked in CLI which do not have --query flag ( ex:- https://github.com/goharbor/harbor-cli/blob/main/cmd/harbor/root/webhook/list.go). |
|
Sorry for the delay.
The list I have given has all the endpoints that support |
|
Changes have been made. Ready for the review @NucleoFusion! |
| flags.Int64VarP(&opts.ProjectID, "project-id", "", 0, "Project ID") | ||
| flags.StringVarP(&opts.Q, "query", "q", "", "Query string to query resources") |
There was a problem hiding this comment.
No query conversion here
|
Please fix merge conflicts for this PR to be merged |
|
@qcserestipy PTAL. you can proceed with the merge now. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #682 +/- ##
=========================================
- Coverage 10.99% 7.62% -3.38%
=========================================
Files 173 271 +98
Lines 8671 13477 +4806
=========================================
+ Hits 953 1027 +74
- Misses 7612 12337 +4725
- Partials 106 113 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds fuzzy, match, and range flags to multiple Harbor CLI commands for more user-friendly query filtering. Instead of using the old --query parameter format, users can now use intuitive flags like --fuzzy name=value, --match key=value, and --range key=min~max. The changes include updates to API handler functions to accept optional ListFlags parameters and corresponding command implementations to build query strings from the new flag inputs.
Changes:
- Updated 13 API handler functions to accept optional ListFlags parameters
- Added fuzzy, match, and range flags to 14 command implementations
- Created new artifact/tags.go command file with full flag support
- Reformatted multi-line flag definitions in quota/list.go and robot/list.go
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/api/webhook_handler.go | Updated ListWebhooks() to accept optional ListFlags |
| pkg/api/scanner_handler.go | Updated ListScanners() to accept optional ListFlags |
| pkg/api/immutable_handler.go | Updated ListImmutable() to accept optional ListFlags |
| pkg/api/artifact_handler.go | Updated ListTags() to accept optional ListFlags |
| cmd/harbor/root/webhook/list.go | Added fuzzy, match, range flags |
| cmd/harbor/root/user/list.go | Added fuzzy, match, range flags |
| cmd/harbor/root/tag/immutable/list.go | Added fuzzy, match, range flags |
| cmd/harbor/root/scanner/list.go | Added fuzzy, match, range flags |
| cmd/harbor/root/robot/list.go | Added fuzzy, match, range flags |
| cmd/harbor/root/repository/list.go | Added fuzzy, match, range flags |
| cmd/harbor/root/replication/policies/list.go | Added fuzzy, match, range flags |
| cmd/harbor/root/replication/executions/list.go | Added fuzzy, match, range flags |
| cmd/harbor/root/registry/list.go | Added fuzzy, match, range flags |
| cmd/harbor/root/quota/list.go | Reformatted multi-line flag definition |
| cmd/harbor/root/project/robot/list.go | Added fuzzy, match, range flags |
| cmd/harbor/root/instance/list.go | Added fuzzy, match, range flags |
| cmd/harbor/root/artifact/tags.go | New file with tag listing command supporting query flags |
| cmd/harbor/root/artifact/list.go | Added fuzzy, match, range flags |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 18 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hey @bupd, PTAL, whenever you get time! |
bupd
left a comment
There was a problem hiding this comment.
@Mujib-Ahasan Thanks for your contribution, Please fix CI and also rebase your commits and resolve conflicts.
Signed-off-by: Mujib Ahasan <ahasanmujib8@gmail.com>
Signed-off-by: Mujib Ahasan <ahasanmujib8@gmail.com>
Signed-off-by: Mujib Ahasan <ahasanmujib8@gmail.com>
Signed-off-by: Mujib Ahasan <ahasanmujib8@gmail.com>
Signed-off-by: Mujib Ahasan <ahasanmujib8@gmail.com>
Signed-off-by: Mujib Ahasan <ahasanmujib8@gmail.com>
Signed-off-by: Mujib Ahasan <ahasanmujib8@gmail.com>
Signed-off-by: Mujib Ahasan <ahasanmujib8@gmail.com>
f8d25bb to
d519831
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated 9 comments.
Comments suppressed due to low confidence (5)
cmd/harbor/root/webhook/list.go:94
- If an output format is requested, the command prints formatted output but then still proceeds to render the interactive table view. This results in double output (and potentially breaks machine-readable output). Consider returning immediately after PrintFormat or moving the table rendering into an else branch.
FormatFlag := viper.GetString("output-format")
if FormatFlag != "" {
err = utils.PrintFormat(resp, FormatFlag)
if err != nil {
return fmt.Errorf("failed to print in %s format: %v", FormatFlag, err)
}
}
webhookViews.ListWebhooks(resp.Payload)
return nil
cmd/harbor/root/tag/immutable/list.go:78
- Typo in the error message: "immutablility" should be "immutability".
return fmt.Errorf("failed to list immutablility rule: %v", err)
cmd/harbor/root/replication/policies/list.go:70
- This error message says "failed to get projects list" but this command is listing replication policies, which makes the message misleading. Consider updating it to mention replication policies.
if err != nil {
return fmt.Errorf("failed to get projects list: %v", utils.ParseHarborErrorMsg(err))
}
cmd/harbor/root/replication/executions/list.go:85
- This error message says "failed to get projects list" but this command is listing replication executions. Consider updating the message to reference replication executions (and possibly include the policy ID).
if err != nil {
return fmt.Errorf("failed to get projects list: %v", utils.ParseHarborErrorMsg(err))
}
cmd/harbor/root/registry/list.go:68
- This error message says "failed to get projects list" but this command is listing registries, which is misleading. Consider updating it to mention registries.
registry, err := api.ListRegistries(opts)
if err != nil {
return fmt.Errorf("failed to get projects list: %v", err)
}


Description
Only
harbor-cli project listandharbor-cli label listsupport fuzzy, match, and range flags. All the other commands does not follow this way to query resource.This PR has been raised to make fuzzy, match, range flag available to other required commands(eg: user, artifact, instance, registry etc).
Resolves #674