prepare cmctl improvements
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
This commit is contained in:
parent
d233758d31
commit
ae287461d0
@ -23,10 +23,24 @@ import (
|
||||
|
||||
// SetExitCode sets the exit code to 1 if the error is not a context.Canceled error.
|
||||
func SetExitCode(err error) {
|
||||
if (err != nil) && errors.Is(err, context.DeadlineExceeded) {
|
||||
errorExitCodeChannel <- 124 // Indicate that there was a timeout error
|
||||
} else if (err != nil) && !errors.Is(err, context.Canceled) {
|
||||
errorExitCodeChannel <- 1 // Indicate that there was an error
|
||||
switch {
|
||||
case err == nil || errors.Is(err, context.Canceled):
|
||||
// If the context was canceled, we don't need to set the exit code
|
||||
case errors.Is(err, context.DeadlineExceeded):
|
||||
SetExitCodeValue(124) // Indicate that there was a timeout error
|
||||
default:
|
||||
SetExitCodeValue(1) // Indicate that there was an error
|
||||
}
|
||||
// If the context was canceled, we don't need to set the exit code
|
||||
}
|
||||
|
||||
// SetExitCode sets the exit code to 1 if the error is not a context.Canceled error.
|
||||
func SetExitCodeValue(code int) {
|
||||
if code != 0 {
|
||||
select {
|
||||
case errorExitCodeChannel <- code:
|
||||
default:
|
||||
// The exit code has already been set to a non-zero value.
|
||||
}
|
||||
}
|
||||
// If the exit code is 0, we don't need to set the exit code
|
||||
}
|
||||
|
||||
@ -38,12 +38,13 @@ var (
|
||||
)
|
||||
|
||||
const (
|
||||
crdsMappingError = `error finding the scope of the object: failed to get restmapping: no matches for kind "Certificate" in group "cert-manager.io"`
|
||||
crdsMapping1Error = `error finding the scope of the object: failed to get restmapping: failed to find API group "cert-manager.io"`
|
||||
crdsMapping2Error = `error finding the scope of the object: failed to get restmapping: no matches for kind "Certificate" in group "cert-manager.io"`
|
||||
crdsNotFoundError = `the server could not find the requested resource (post certificates.cert-manager.io)`
|
||||
)
|
||||
|
||||
var (
|
||||
regexErrCertManagerCRDsNotFound = regexp.MustCompile(`^(` + regexp.QuoteMeta(crdsMappingError) + `|` + regexp.QuoteMeta(crdsNotFoundError) + `)$`)
|
||||
regexErrCertManagerCRDsNotFound = regexp.MustCompile(`^(` + regexp.QuoteMeta(crdsMapping1Error) + `|` + regexp.QuoteMeta(crdsMapping2Error) + `|` + regexp.QuoteMeta(crdsNotFoundError) + `)$`)
|
||||
regexErrWebhookServiceFailure = regexp.MustCompile(`Post "(.*)": service "(.*)-webhook" not found`)
|
||||
regexErrWebhookDeploymentFailure = regexp.MustCompile(`Post "(.*)": (.*): connect: connection refused`)
|
||||
regexErrWebhookCertificateFailure = regexp.MustCompile(`Post "(.*)": x509: certificate signed by unknown authority`)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user