Skip to content

feat(user): add fuzzy, match, range flags for commands#682

Open
Mujib-Ahasan wants to merge 5 commits intogoharbor:mainfrom
Mujib-Ahasan:new-query-flags
Open

feat(user): add fuzzy, match, range flags for commands#682
Mujib-Ahasan wants to merge 5 commits intogoharbor:mainfrom
Mujib-Ahasan:new-query-flags

Conversation

@Mujib-Ahasan
Copy link

Description

Only harbor-cli project list and harbor-cli label list support 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

Signed-off-by: Mujib Ahasan <ahasanmujib8@gmail.com>
@Mujib-Ahasan
Copy link
Author

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 user list command for now. Could you please help me to get the keys for other commands?!

@NucleoFusion
Copy link
Contributor

@Mujib-Ahasan the keys are the fields/keys in the JSON object they return. They are available on the demo.goharbor.io swagger api

@Mujib-Ahasan
Copy link
Author

Great, Thank you @NucleoFusion!

Signed-off-by: Mujib Ahasan <ahasanmujib8@gmail.com>
@Mujib-Ahasan
Copy link
Author

@NucleoFusion , PTAL at these changes. after that I will do some tests against my local setup.

@NucleoFusion
Copy link
Contributor

@Mujib-Ahasan

  • Repositories
    • All Repo's
    • Project Repositories
  • Artifacts
  • Tags
  • Accessories
  • Auditlogs
  • Preheat
    • instances
    • policies
    • executions
    • execution tasks
  • Immutable Tag Rules
  • Webhooks
    • policies
    • execs
    • execution tasks
  • Robots
  • Replication
    • policies
    • executions
    • execution tasks
  • Registries
  • Scanner
  • Users
  • Labels
  • SecurityHub - Vuln List

All these are supported via the q param as per the swagger API. Can you make a checklist and check if they all are implemented as the q param.
And if they are not present in the CLI as of now, please mention the same

@Mujib-Ahasan
Copy link
Author

Mujib-Ahasan commented Feb 11, 2026

  • Repositories (--query)
    • All Repos
    • Project Repositories
  • Artifacts (--query)
  • Tags ( No CLI)
  • Immutable Tags Rule (CLI implemented, --query not present)
  • Accessories (No CLI)
  • Auditlogs (--query)
  • Preheat
    • instances (--query)
    • policies (No CLI)
    • executions (No CLI)
    • execution tasks (No CLI)
  • Webhooks
    • policies(CLI implemented, --query not present)
    • execs (No CLI)
    • execution tasks (No CLI)
  • Robots (--query)
  • Replication
    • policies (--query)
    • executions (--query)
    • execution tasks (No CLI)
  • Registries (--query)
  • Scanner(CLI implemented, --query not present)
  • Users (--query)
  • Labels )--query)
  • SecurityHub - Vuln List(No CLI)

(only for list subcommand)

@NucleoFusion PTAL.

@NucleoFusion
Copy link
Contributor

Have you done all those? In the checklist that have CLI present?
If so I will have a look ASAP

@Mujib-Ahasan
Copy link
Author

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).

@NucleoFusion
Copy link
Contributor

NucleoFusion commented Feb 22, 2026

Sorry for the delay.
I can see that even though some of the CLI Commands dont have --query builtin, but their API in Harbor does support it.
For example,

tags/immutable/list.go, artifact/tags.go

image image

The list I have given has all the endpoints that support q param as per the API. not the CLI.
Please check and add to even those that done have the --query currently.
@Mujib-Ahasan

Signed-off-by: Mujib Ahasan <ahasanmujib8@gmail.com>
Signed-off-by: Mujib Ahasan <ahasanmujib8@gmail.com>
@Mujib-Ahasan
Copy link
Author

Changes have been made. Ready for the review @NucleoFusion!

Comment on lines 116 to 117
flags.Int64VarP(&opts.ProjectID, "project-id", "", 0, "Project ID")
flags.StringVarP(&opts.Q, "query", "q", "", "Query string to query resources")
Copy link
Contributor

Choose a reason for hiding this comment

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

No query conversion here

Signed-off-by: Mujib Ahasan <ahasanmujib8@gmail.com>
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.

lgtm

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.

refactor: Refactor old commands that support the q query paramater to now utilize the new format.

2 participants