Add default case to handle invalid --output flag in version command#6033
Add default case to handle invalid --output flag in version command#6033kfess wants to merge 1 commit intokubernetes-sigs:masterfrom
--output flag in version command#6033Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: kfess The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @kfess When fixing a bug, please add sufficient test cases to verify the fix and prevent regressions。 |
|
@koba1t |
|
I'd like to confirm the expected error output behavior when an invalid Current behaviorkubectl: $ kubectl version --output=yml
error: --output must be 'yaml' or 'json'kustomize (current behavior shows help text as well): $ kustomize version --output=yml
Error: --output must be 'yaml' or 'json'
Usage:
kustomize version [flags]
Examples:
kustomize version
Flags:
-h, --help help for version
-o, --output string One of 'yaml' or 'json'.
Global Flags:
--stack-trace print a stack-trace on error
exit status 1I believe the kubectl behavior (showing only the error message without the usage/help text) is better for this case. |
|
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
Description
Add default case for invalid
--outputflag in version commandWhen users specify an invalid value for the
--outputflag (e.g.,--output=yml),the command fails silently with no error message or output.
This PR adds a default case to the switch statement that returns a clear error message,
matching the error handling pattern used in kubectl version.
Output after adding default block
Fixes #6032
Additional context
This is my first contribution to the kustomize codebase.
Please let me know if there's anything I should adjust to better align with the project's conventions.