Skip to content

fix(webhook): avoid rendering interactive table when output format is… - #1099

Open
TaichKarna wants to merge 3 commits into
goharbor:mainfrom
TaichKarna:fix/webhook-list-output-format
Open

TaichKarna wants to merge 3 commits into
goharbor:mainfrom
TaichKarna:fix/webhook-list-output-format

Conversation

@TaichKarna

@TaichKarna TaichKarna commented Sep 14, 2026

Copy link
Copy Markdown

Description

This PR fixes a bug where harbor webhook list [PROJECT_NAME] rendered the interactive Bubble Tea table UI in addition to formatted output when --output-format (e.g. -o json) was specified.

Type of Change

Please select the relevant type.

  • Bug fix
  • New feature
  • Refactor
  • Documentation update
  • Chore / maintenance

Changes

  • Placed webhookViews.ListWebhooks inside an else branch in cmd/harbor/root/webhook/list.go when output-format is specified.
  • Grouped listWebhooks and listWebhooksView package variables in list.go to support unit testing.
  • Added unit test for webhook list to verify --output-format behavior.
  • Aligned webhook list behavior with other CLI list commands (schedule list, robot list, registry list, repository list, project list).

Testing

  • Verified locally with ./bin/harbor-cli webhook list demo -o json against local Harbor instance. Only formatted JSON is printed.
  • Added unit test covering webhook list --output-format.
  • Formatted with gofmt -s -w . and verified full unit test suite passes: go test ./....

… specified

Signed-off-by: TaichKarna <taichikarna@gmail.com>

@JituRewar JituRewar left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@TaichKarna One suggestion from my side : could we add a unit test covering - output-format (e.g. json) to verify that webhookViews.ListWebhooks is not invoked/rendered when a format is specified? This would help prevent the same regression from being introduced again in the future.
And the control-flow change looks good to me.

Signed-off-by: TaichKarna <taichikarna@gmail.com>
@TaichKarna

Copy link
Copy Markdown
Author

@TaichKarna One suggestion from my side : could we add a unit test covering - output-format (e.g. json) to verify that webhookViews.ListWebhooks is not invoked/rendered when a format is specified? This would help prevent the same regression from being introduced again in the future. And the control-flow change looks good to me.

Yes, added one

Signed-off-by: TaichKarna <taichikarna@gmail.com>
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]: harbor webhook list cmd renders both interactive ui and json when format specified is json

2 participants