e2e: allow kubectlDelete to succeed with NotFound error

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos
2022-04-25 14:23:26 +02:00
committed by mergify[bot]
parent 17fea0459d
commit eab2ec42bf
2 changed files with 42 additions and 3 deletions

View File

@ -127,3 +127,33 @@ func isAlreadyExistsCLIError(err error) bool {
return true
}
// isNotFoundCLIError checks for "is not found" error from kubectl CLI.
func isNotFoundCLIError(err error) bool {
if err == nil {
return false
}
// if multiple resources already exists. each error is separated by newline
stdErr := getStdErr(err.Error())
if stdErr == "" {
return false
}
stdErrs := strings.Split(stdErr, "\n")
for _, s := range stdErrs {
// If the string is just a new line continue
if strings.TrimSuffix(s, "\n") == "" {
continue
}
// Ignore warnings
if strings.Contains(s, "Warning") {
continue
}
// Resource not found error message
if !strings.Contains(s, "Error from server (NotFound)") {
return false
}
}
return true
}