-
Notifications
You must be signed in to change notification settings - Fork 8
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
Pass context through cmd and use RunE instead of Run #33
Conversation
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
@@ -47,6 +47,7 @@ func NewCertManagerCtlCommand(ctx context.Context, in io.Reader, out, err io.Wri | |||
return logf.ValidateAndApply(logOptions) | |||
}, | |||
SilenceErrors: true, // Errors are already logged when calling cmd.Execute() | |||
SilenceUsage: true, // Don't print usage when an error occurs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not want cobra to print the usage every time there is an error.
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: inteon The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Pass context by calling
cmd.ExecuteContext(ctx)
and retrieving it usingcmd.Context()
. Also, callcmdutil.CheckErr
only in main.go and use RunE and PreRunE to pass the error to main.go.An example of
cmctl check api -v4 --logging-format=json --wait=5m
still working: