Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error invalid value for project version appears without let us know what values are available #1914

Closed
camilamacedo86 opened this issue Dec 17, 2020 · 11 comments · Fixed by #1937
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Milestone

Comments

@camilamacedo86
Copy link
Member

camilamacedo86 commented Dec 17, 2020

Unable to use the help to check the plugins versions available for an project version:

 $ kubebuilder init --project-version=v3-alpha --plugins=h
2020/12/17 12:00:07 invalid value for project version (regex used for validation is '[1-9][0-9]*(?:-(?:alpha|beta))?')

When I would expect to see:

$ kubebuilder init --project-version=3
Error: no resolved plugins, please specify plugins with --project-version or/and --plugins flags
Usage:
  kubebuilder init [flags]

Examples:
  # Help for initializing a project with version "2"
  kubebuilder init --project-version="2" -h

  # Help for initializing a project with version "3-alpha"
  kubebuilder init --project-version="3-alpha" -h

Flags:
  -h, --help                     help for init
      --plugins strings          Name and optionally version of the plugin to initialize the project with. Available plugins: ("go.kubebuilder.io/v2", "go.kubebuilder.io/v3")
      --project-version string   project version, possible values: ("2", "3-alpha") (default "3-alpha")

2020/12/17 12:12:19 no resolved plugins, please specify plugins with --project-version or/and --plugins flags

PS.: It shows a bug introduced in the latest changes.
c/c @estroz @Adirio

@camilamacedo86 camilamacedo86 added the kind/bug Categorizes issue or PR as related to a bug. label Dec 17, 2020
@Adirio
Copy link
Contributor

Adirio commented Dec 17, 2020

Project versions do not support the v prefix:

$ kubebuilder init --project-version=3-alpha --plugins=h

@estroz
Copy link
Contributor

estroz commented Dec 17, 2020

Yeah this is a validation error. I don't see what better error kubebuilder could produce if the project version doesn't have the correct format.

/remove-kind bug

@k8s-ci-robot k8s-ci-robot removed the kind/bug Categorizes issue or PR as related to a bug. label Dec 17, 2020
@Adirio
Copy link
Contributor

Adirio commented Dec 17, 2020

Closing this as it should be solved just by removing the invalid v character. Reopen if the error is still present afterwards.

@Adirio
Copy link
Contributor

Adirio commented Dec 17, 2020

/close

@k8s-ci-robot
Copy link
Contributor

@Adirio: Closing this issue.

In response to this:

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@camilamacedo86
Copy link
Member Author

camilamacedo86 commented Dec 17, 2020

Hi @Adirio @estroz,

The point here is that invalid value for project version (regex used for validation is '[1-9][0-9]*(?:-(?:alpha|beta))?') are not helpful for the users at all. put yourself in the user fits, how you would know the possible project version available and what info you should pass with this error mensage?

We should output the help with that. For all CLI errors, we should output the help and not ONLY the error itself. Is not the common behaviour for the CLI? PS.: I believe that it was showing the help before the latest changes.

$ kubebuilder init --project-version=3
Error: no resolved plugins, please specify plugins with --project-version or/and --plugins flags
Usage:
 kubebuilder init [flags]

Examples:
 # Help for initializing a project with version "2"
 kubebuilder init --project-version="2" -h

 # Help for initializing a project with version "3-alpha"
 kubebuilder init --project-version="3-alpha" -h

Flags:
 -h, --help                     help for init
     --plugins strings          Name and optionally version of the plugin to initialize the project with. Available plugins: ("go.kubebuilder.io/v2", "go.kubebuilder.io/v3")
     --project-version string   project version, possible values: ("2", "3-alpha") (default "3-alpha")

@estroz
Copy link
Contributor

estroz commented Dec 17, 2020

Outputting command help is fine with me, or a list of available project versions.

@camilamacedo86 camilamacedo86 added the kind/bug Categorizes issue or PR as related to a bug. label Dec 18, 2020
@camilamacedo86
Copy link
Member Author

It is a bug because what is expected for any CLI/tool command is:

  • If an invalid arg or value be used to run the command then, the tool should return error with the help
  • The help should provide the possible options available

@Adirio
Copy link
Contributor

Adirio commented Dec 18, 2020

I 100% agree that printing the regex is not a very good UX, I will work on showing the available project versions instead of the regex. IMO printing the whole command help should be reserved for those cases where the use intention is not clear. In this case the intention is clearly to provide a valid project version but he failed, so a clear error message that includes available project versions should be clear an concise while printing the whole command help may add noise.

@Adirio
Copy link
Contributor

Adirio commented Jan 4, 2021

/assign

@camilamacedo86 camilamacedo86 added the triage/accepted Indicates an issue or PR is ready to be actively worked on. label Jan 12, 2021
@camilamacedo86 camilamacedo86 added this to the 3.1.0 milestone Jan 12, 2021
@Adirio
Copy link
Contributor

Adirio commented Jan 13, 2021

With #1937, the output to kubebuilder init --project-version=v3-alpha --plugins=h is:

Error: invalid value for project version (regex used for validation is '[1-9][0-9]*(?:-(?:alpha|beta))?')
Usage:
  kubebuilder [flags]

Examples:
The first step is to initialize your project:
    kubebuilder init --project-version=<PROJECT VERSION> --plugins=<PLUGIN KEYS>

<PLUGIN KEYS> is a comma-separated list of plugin keys from the following table
and <PROJECT VERSION> a supported project version for these plugins.

          Plugin keys | Supported project versions
----------------------+----------------------------
 go.kubebuilder.io/v2 |                 2, 3-alpha
 go.kubebuilder.io/v3 |                    3-alpha

For more specific help for the init command of a certain plugins and project version
configuration please run:
    kubebuilder init --help --project-version=<PROJECT VERSION> --plugins=<PLUGIN KEYS>

Default project version: 3-alpha
Default plugin keys: "go.kubebuilder.io/v3"

After the project has been initialized, run
    kubebuilder --help
to obtain further info about available commands.

Flags:
  -h, --help                     help for kubebuilder
      --plugins strings          plugin keys of the plugin to initialize the project with
      --project-version string   project version (default "3-alpha")

2021/01/13 07:39:49 invalid value for project version (regex used for validation is '[1-9][0-9]*(?:-(?:alpha|beta))?')

Should this be enough? Any suggested changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants