Skip to content

Conversation

@kfess
Copy link
Member

@kfess kfess commented Dec 1, 2025

Description

Add default case for invalid --output flag in version command

When users specify an invalid value for the --output flag (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

$ 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 1

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.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 1, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: kfess
Once this PR has been reviewed and has the lgtm label, please assign varshaprasad96 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Dec 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kustomize version command: invalid --output value fails silently

2 participants