Skip to content

Commit 1ba4ff9

Browse files
fix: function IsCRDNotFound should also work with NoResourceMatchErrors
1 parent e0442e0 commit 1ba4ff9

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pkg/utils/errors.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ func IsCRDNotFound(err error) bool {
1515
return true
1616
}
1717

18+
// check if err tree contains a "NoResourceMatchError" error.
19+
if errors.Is(err, &meta.NoResourceMatchError{}) {
20+
return true
21+
}
22+
1823
// check if err tree contains a "ErrResourceDiscoveryFailed" error.
1924
var rdfErr *apiutil.ErrResourceDiscoveryFailed
2025
if !errors.As(err, &rdfErr) {

pkg/utils/errors_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ func TestIsCRDNotFound(t *testing.T) {
2525
err: &meta.NoKindMatchError{},
2626
want: true,
2727
},
28+
{
29+
name: "no resource match error",
30+
err: &meta.NoResourceMatchError{},
31+
want: true,
32+
},
2833
{
2934
name: "resource discovery failed error",
3035
err: &apiutil.ErrResourceDiscoveryFailed{},

0 commit comments

Comments
 (0)