Skip to content

Fix: make harbor registry update non-interactive when flags are provided#901

Open
rakshityadav1868 wants to merge 6 commits into
goharbor:mainfrom
rakshityadav1868:non-interactive-registry-update
Open

Fix: make harbor registry update non-interactive when flags are provided#901
rakshityadav1868 wants to merge 6 commits into
goharbor:mainfrom
rakshityadav1868:non-interactive-registry-update

Conversation

@rakshityadav1868

Copy link
Copy Markdown

Description

The harbor registry update command incorrectly opens interactive prompts even when all update values are explicitly passed through CLI flags.

Type of Change

  • Bug fix

Changes Made

File: cmd/harbor/root/registry/update.go

Untitled design(2)

Signed-off-by: Rakshit Yadav <yadavrakshit60@gmail.com>

@NucleoFusion NucleoFusion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I dont think this is the best way to do it,
please refer to other commands where we do the same, and how it happens there.

Signed-off-by: Rakshit Yadav <yadavrakshit60@gmail.com>
@rakshityadav1868

Copy link
Copy Markdown
Author

@NucleoFusion
Updated the implementation to follow the existing pattern used in instance/update.go by moving the flag change detection into a helper function instead of keeping the inline condition.

Comment thread cmd/harbor/root/registry/update.go
Signed-off-by: Rakshit Yadav <yadavrakshit60@gmail.com>
@rakshityadav1868

Copy link
Copy Markdown
Author

@NucleoFusion
Done instead of flags used opts

@NucleoFusion NucleoFusion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Okay so, in the case of this command, we were not checking flags at all
So,
Traditionally, we check the minimal flags required for the command to execute.
From the API Docs, there is no specific amount of flags that are either required or not required.

For this, it would be best to discuss in the meeting what amount of flags from the registry model

{
  "name": "string",
  "description": "string",
  "url": "string",
  "credential_type": "string",
  "access_key": "string",
  "access_secret": "string",
  "insecure": true
}

we consider to be required, and what we dont.
This may even end up amending how we currently process the model

@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 9.33%. Comparing base (60ad0bd) to head (10938e7).
⚠️ Report is 188 commits behind head on main.

Files with missing lines Patch % Lines
cmd/harbor/root/registry/update.go 0.00% 21 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             main    #901      +/-   ##
=========================================
- Coverage   10.99%   9.33%   -1.66%     
=========================================
  Files         173     321     +148     
  Lines        8671   16099    +7428     
=========================================
+ Hits          953    1503     +550     
- Misses       7612   14462    +6850     
- Partials      106     134      +28     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Rakshit Yadav <yadavrakshit60@gmail.com>
@rakshityadav1868

Copy link
Copy Markdown
Author

@NucleoFusion updated the flow now for updating registry through flag requires Id as a mandatory field!!

Screen.Recording.2026-06-25.at.12.08.26.AM.mp4

@bupd bupd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No, Instead of making ID mandatory i would do a roundtrip with just name to get the id if it fails i would say name is not found. and throw err msg to user.

also the direction this pr is heading is not consistent with other cmds present in the harbor-cli. I suggest @rakshityadav1868 to reconsider the implementation with how other cmds treat this behaviour before implementing.

keeping things consistent across pkgs is more important than a random fix.

Signed-off-by: Rakshit Yadav <yadavrakshit60@gmail.com>
@rakshityadav1868

Copy link
Copy Markdown
Author

Hey @bupd,

I've addressed the review feedback and aligned the implementation with the existing Harbor CLI update patterns.

Changes made

  • Replaced the inline update flag handling with hasUpdateFlagChanges() using flags.Changed(...) to determine interactive vs. non-interactive mode.
  • Moved the flag application logic into applyUpdateFlags() to keep RunE cleaner and consistent with other update commands.
  • Preserved the existing interactive TUI flow when no update flags are provided.
  • Non-interactive updates now skip the TUI and update only the explicitly provided fields while preserving the remaining registry configuration.
  • Continued using the existing registry name to ID lookup (api.GetRegistryIdByName) to stay consistent with other registry commands.

@rakshityadav1868

Copy link
Copy Markdown
Author
Screen.Recording.2026-06-25.at.1.53.02.PM.mov

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.

[bug]: Missing non-interactive registry update mode

3 participants