troubleshoot: RFE (small suggestion): Error faced when we run `kubectl preflight` does not clarifies what is missing and why

Describe the rationale for the suggested feature.

If we install troubleshoot and run kubectl preflight to check it is ok the following error is returned which can bring confusion and does not let us know what is properly missing and why, or if the tool is properly installed.

$ kubectl preflight Error: requires at least 1 arg(s), only received 0

Describe the feature

Why the URL is required as arg? Could I am as user use any other value that is not https://preflight.replicated.com?

What about simplify its usage by:

  • Using flag instead of arg to pass the URL https://preflight.replicated.com
  • If the URL not to be set, then its default value will be used which would be a constant with https://preflight.replicated.com

So that, I can run the command with kubectl preflight only.

Describe alternatives you’ve considered

Return a better message so that we can clarifies that it is missing a URL with its default value.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 17 (17 by maintainers)

Most upvoted comments

It just occurred to me that we did not address the original problem which was ambiguity of the error message seen in a CLI is run with no arguments.

Are we happy with printing the usage text if there are no arguments passed in as I had described https://github.com/replicatedhq/troubleshoot/issues/824#issuecomment-1317338529?

Hu that’s interesting, I wonder if we should revisit that. Should support bundle expect a spec, pre-flight expect a spec, and analyze expect a spec?

I think that’s a good objective, We’d then have ./bin/<cmd> <spec> <options>

Would adding the following two changes improve the situation?

  • Improve the usage description to show what the url ought to be
  • Show the --help output whenever there are errors parsing cli flags

Example

✔ ~/repos/replicated/troubleshoot [em/sbctl-pod-logs-744 {origin/em/sbctl-pod-logs-744}|✚ 1…1⚑ 1]
[evans] $ ./bin/preflight
A preflight check is a set of validations that can and should be run to ensure
that a cluster meets the requirements to run an application.

The [url] argument is either an oci://.., https://.. or a local path to a yaml file.

Usage:
  preflight [url] [flags]
  preflight [command]

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  help        Help about any command
  version     Print the current version and exit

Flags:
      --as string                      Username to impersonate for the operation. User could be a regular user or a service account in a namespace.

<truncated>

Use "preflight [command] --help" for more information about a command.
✘-1 ~/repos/replicated/troubleshoot [em/sbctl-pod-logs-744 {origin/em/sbctl-pod-logs-744}|✚ 1…1⚑ 1]