Skip to content

Commit d68e764

Browse files
[Backport release/2.0.x] refactor: use apierrors.IsNotFound instead of strings.Contains (#2804)
Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com> Co-authored-by: Jintao Zhang <zhangjintao9020@gmail.com>
1 parent c8123b3 commit d68e764

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

ingress-controller/internal/admission/validator.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package admission
33
import (
44
"context"
55
"fmt"
6-
"strings"
76

87
"github.com/go-logr/logr"
98
"github.com/kong/go-kong/kong"
@@ -439,7 +438,7 @@ func (validator KongHTTPValidator) ValidateGateway(
439438
// validate the gatewayclass reference
440439
gwc := gatewayapi.GatewayClass{}
441440
if err := validator.ManagerClient.Get(ctx, client.ObjectKey{Name: string(gateway.Spec.GatewayClassName)}, &gwc); err != nil {
442-
if strings.Contains(err.Error(), "not found") {
441+
if apierrors.IsNotFound(err) {
443442
return true, "", nil // not managed by this controller
444443
}
445444
return false, ErrTextCantRetrieveGatewayClass, err

0 commit comments

Comments
 (0)