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

prevent printing usages on error #457

Merged
merged 1 commit into from
Nov 22, 2024
Merged

Conversation

nabuskey
Copy link
Collaborator

Set SilenceUsage: true, for commands to prevent usages from being printed every time an error occurs.

before:

idpbuilder get secrets
Error: getting kube config: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
Usage:
  idpbuilder get secrets [flags]

Flags:
  -h, --help   help for secrets

Global Flags:
      --color              Enable colored log messages.
  -l, --log-level string   Set the log verbosity. Supported values are: debug, info, warn, and error. (default "info")
  -o, --output string      Output format. json or yaml.
  -p, --packages strings   names of packages.

getting kube config: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable

After:

idpbuilder get secrets
Error: getting kube config: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
getting kube config: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable

fixes: #439

Signed-off-by: Manabu McCloskey <[email protected]>
Copy link
Contributor

@cmoulliard cmoulliard left a comment

Choose a reason for hiding this comment

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

I did a test where I provided a wrong package to the command

Before:

❯ ./idpbuilder get secrets -p argocdddd
Error: listing secrets: failed to get API group resources: unable to retrieve the complete list of server APIs: v1: Get "https://127.0.0.1:51605/api/v1": dial tcp 127.0.0.1:51605: connect: connection refused
Usage:
  idpbuilder get secrets [flags]

Flags:
  -h, --help   help for secrets

Global Flags:
      --color              Enable colored log messages.
  -l, --log-level string   Set the log verbosity. Supported values are: debug, info, warn, and error. (default "info")
  -o, --output string      Output format. json or yaml.
  -p, --packages strings   names of packages.

listing secrets: failed to get API group resources: unable to retrieve the complete list of server APIs: v1: Get "https://127.0.0.1:51605/api/v1": dial tcp 127.0.0.1:51605: connect: connection refused

After:

❯ ./idpbuilder get secrets -p argocdddd
Error: listing secrets: failed to get API group resources: unable to retrieve the complete list of server APIs: v1: Get "https://127.0.0.1:51605/api/v1": dial tcp 127.0.0.1:51605: connect: connection refused
listing secrets: failed to get API group resources: unable to retrieve the complete list of server APIs: v1: Get "https://127.0.0.1:51605/api/v1": dial tcp 127.0.0.1:51605: connect: connection refused

Note: We should review how we log messages too as error is reported twice. This ticket could be used for that purpose: #450

@nabuskey
Copy link
Collaborator Author

Yeah we should definitely look into why errors are being printed twice.

@nabuskey nabuskey merged commit 4d9f1a0 into cnoe-io:main Nov 22, 2024
5 checks passed
@nabuskey nabuskey deleted the silent-usage branch November 22, 2024 15:40
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.

[Suggestion]: Remove usage from message logged when error occurs
2 participants