Repository navigation
fix(labels): skip interactive form in label update when flags are set - #1108
Open
bhuvan-somisetty wants to merge 2 commits into
Open
bhuvan-somisetty wants to merge 2 commits into
bhuvan-somisetty wants to merge 2 commits into
Conversation
harbor label update always opened the interactive form, even when --name, --color or --description were passed, so the command could not be used non-interactively and exited via log.Fatal without a TTY. Apply the explicitly set flags and only fall back to the form when none were given, matching label create. Also reject an empty --name and drop the check for a --scope flag that update never registers. Fixes goharbor#1107 Signed-off-by: bhuvan-somisetty <somisettybhuvan5@gmail.com>
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
An explicit empty --color skipped the form's non-empty validation and was sent to the API. Move the flag-path checks into validateLabelUpdate, which rejects both an empty name and an empty color, and cover it with unit tests. Signed-off-by: bhuvan-somisetty <somisettybhuvan5@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
harbor label updatealways opened the interactive form, even when--name,--coloror--descriptionwere passed. That made it impossible to use in scripts or CI: without a TTY the form fails andlog.Fatalexits before the update is sent.This PR applies the explicitly set flags directly and only opens the form when none of them are given, matching how
harbor label createalready behaves.Type of Change
Please select the relevant type.
Changes
applyLabelUpdateFlagsincmd/harbor/root/labels/update.go, which copies the set update flags onto the label and reports whether any were set;update.UpdateLabelViewnow runs only when it returnsfalse.validateLabelUpdaterejects an empty--nameor--colorwith an error, applying the same rules the interactive form enforces.flags.Changed("scope")check, sincelabel updatenever registers a--scopeflag. Lookup flags (--global,--project,--project-id) don't count as updates.cmd/harbor/root/labels/update_test.go, which tests the flag set and the flag-to-label mapping (no flags, single fields, clearing the description, all fields, lookup-only flags) and the empty name/color validation.Testing
Usage after this change: