Skip to content

Feat: support --registry-name for proxy cache project creation#904

Open
rakshityadav1868 wants to merge 3 commits into
goharbor:mainfrom
rakshityadav1868:project-registry-name-support
Open

Feat: support --registry-name for proxy cache project creation#904
rakshityadav1868 wants to merge 3 commits into
goharbor:mainfrom
rakshityadav1868:project-registry-name-support

Conversation

@rakshityadav1868
Copy link
Copy Markdown

Description

Previously, users had to manually list registries, parse the registry ID, and pass --registry-id during project creation. With this update, users can now directly provide the registry name and the CLI will internally resolve it to the corresponding registry ID before sending the request to Harbor.
This keeps the existing Harbor architecture unchanged, since Harbor still internally operates using registry_id.

Changes

1. Added --registry-name flag

Added support for a new CLI flag:

  • --registry-name

2. Added registry name to ID resolution

Added logic to resolve registry names using:

  • api.GetRegistryIdByName(..)

3. Updated validation logic

Updated proxy cache validation to support both:

  • --registry-id

  • --registry-name


Untitled design(3)

Untitled design(4)

Comment thread cmd/harbor/root/project/create.go Outdated
Comment thread cmd/harbor/root/project/create.go
@rakshityadav1868
Copy link
Copy Markdown
Author

@NucleoFusion
Shorten the string and added a condition when both name and id is provided it throws an error.

Screenshot 2026-05-09 at 12 21 35 PM

Copy link
Copy Markdown
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.

The implementation works, yes
But could you also modify the view to accommodate this?
Right now, if we only provide the --registry-name the view opens (as it should) but it does not auto-select the ID which was provided.

Steps to Reproduce

  1. Run harbor-cli project create --registry-name dockerhub --proxy-cache
  2. Fill the Initial details, and move to second page.
    ERR: In the second page, dockerhub is not the one selected.

@rakshityadav1868
Copy link
Copy Markdown
Author

@NucleoFusion i think in this Pr it is fixed i have tried on this Pr branch cant find the issue
https://github.com/user-attachments/assets/e623bbda-b237-4ef1-b64a-425e1b097b86

@NucleoFusion
Copy link
Copy Markdown
Contributor

@NucleoFusion i think in this Pr it is fixed i have tried on this Pr branch cant find the issue github.com/user-attachments/assets/e623bbda-b237-4ef1-b64a-425e1b097b86

Try some other registry
broadcom or somethign maybe.
There are a lot of registries, its only showing 2, thats not correct

@rakshityadav1868
Copy link
Copy Markdown
Author

@NucleoFusion
means under registryId all registries should be shown ? right ?

@Famous077
Copy link
Copy Markdown

Hi @rakshityadav1868 , Before raising any PR, you have to ask is there anyone working on this issue or not? Your activity is totally against the Open source contributing guideline.

Signed-off-by: Rakshit Yadav <yadavrakshit60@gmail.com>
Signed-off-by: Rakshit Yadav <yadavrakshit60@gmail.com>
Signed-off-by: Rakshit Yadav <yadavrakshit60@gmail.com>
@rakshityadav1868 rakshityadav1868 force-pushed the project-registry-name-support branch from f552bd6 to b1bca1a Compare May 11, 2026 05:23
@rakshityadav1868
Copy link
Copy Markdown
Author

Hi @NucleoFusion
Implemented the changes with conditional form groups instead of WithHideFunc.

Reason for not using WithHideFunc:

  • The select component was still being rendered internally, even when hidden
  • That was causing the Huh viewport/rendering issue with registry selection

Current approach:

  • The registry select group is only appended when required
  • If --registry-id or --registry-name is already provided, the select component is not rendered at all
Screen.Recording.2026-05-11.at.10.59.22.AM.mp4

@rakshityadav1868
Copy link
Copy Markdown
Author

rakshityadav1868 commented May 11, 2026

One small clarification currently if neither --registry-id nor --registry-name is provided with --proxy-cache, it already throws an error before reaching the form flow (this behavior existed before my changes as well).

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.

[feature]: Create project with --registry-name instead of --registry-id

3 participants