Skip to content

Commit

Permalink
Use apierr directly
Browse files Browse the repository at this point in the history
Signed-off-by: Andrii Korotkov <[email protected]>
  • Loading branch information
andrii-korotkov-verkada committed Dec 2, 2024
1 parent c1af11e commit f0f6300
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
9 changes: 5 additions & 4 deletions test/e2e/fixture/applicationsets/utils/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
log "github.com/sirupsen/logrus"

"k8s.io/apimachinery/pkg/api/equality"
apierr "k8s.io/apimachinery/pkg/api/errors"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -117,23 +118,23 @@ func EnsureCleanState(t *testing.T) {
func() error {
// Delete the applicationset-e2e namespace, if it exists
err := fixtureClient.KubeClientset.CoreV1().Namespaces().Delete(context.Background(), ApplicationsResourcesNamespace, v1.DeleteOptions{PropagationPolicy: &policy})
if err != nil && !errors.IsNotFound(err) { // 'not found' error is expected
if err != nil && !apierr.IsNotFound(err) { // 'not found' error is expected
return err
}
return nil
},
func() error {
// Delete the argocd-e2e-external namespace, if it exists
err := fixtureClient.KubeClientset.CoreV1().Namespaces().Delete(context.Background(), string(ArgoCDExternalNamespace), v1.DeleteOptions{PropagationPolicy: &policy})
if err != nil && !errors.IsNotFound(err) { // 'not found' error is expected
if err != nil && !apierr.IsNotFound(err) { // 'not found' error is expected
return err
}
return nil
},
func() error {
// Delete the argocd-e2e-external namespace, if it exists
err := fixtureClient.KubeClientset.CoreV1().Namespaces().Delete(context.Background(), string(ArgoCDExternalNamespace2), v1.DeleteOptions{PropagationPolicy: &policy})
if err != nil && !errors.IsNotFound(err) { // 'not found' error is expected
if err != nil && !apierr.IsNotFound(err) { // 'not found' error is expected
return err
}
return nil
Expand Down Expand Up @@ -275,7 +276,7 @@ func cleanUpNamespace(fixtureClient *E2EFixtureK8sClient, namespace string) erro
msg = fmt.Sprintf("namespace '%s' still exists, after delete", namespace)
}

if msg == "" && err != nil && errors.IsNotFound(err) {
if msg == "" && err != nil && apierr.IsNotFound(err) {
// Success is an error containing 'applicationset-e2e' not found.
return nil
}
Expand Down
5 changes: 0 additions & 5 deletions util/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"os"

log "github.com/sirupsen/logrus"
apierr "k8s.io/apimachinery/pkg/api/errors"
)

const (
Expand Down Expand Up @@ -51,7 +50,3 @@ func Fatalf(exitcode int, format string, args ...interface{}) {
log.RegisterExitHandler(exitfunc)
log.Fatalf(format, args...)
}

func IsNotFound(err error) bool {
return apierr.IsNotFound(err)
}

0 comments on commit f0f6300

Please sign in to comment.