From 6aad00ff73d10378d33d615505239c5373a1108b Mon Sep 17 00:00:00 2001 From: Tarun Gupta Akirala Date: Mon, 7 Aug 2023 12:08:09 -0700 Subject: [PATCH 1/2] client-go: chore: implement `Is` interface for `ErrGroupDiscoveryFailed` Signed-off-by: Tarun Gupta Akirala --- staging/src/k8s.io/client-go/discovery/discovery_client.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/staging/src/k8s.io/client-go/discovery/discovery_client.go b/staging/src/k8s.io/client-go/discovery/discovery_client.go index a4f083a1ac3..a6c6718246e 100644 --- a/staging/src/k8s.io/client-go/discovery/discovery_client.go +++ b/staging/src/k8s.io/client-go/discovery/discovery_client.go @@ -415,6 +415,11 @@ func (e *ErrGroupDiscoveryFailed) Error() string { return fmt.Sprintf("unable to retrieve the complete list of server APIs: %s", strings.Join(groups, ", ")) } +func (e *ErrGroupDiscoveryFailed) Is(target error) bool { + _, ok := target.(*ErrGroupDiscoveryFailed) + return ok +} + // IsGroupDiscoveryFailedError returns true if the provided error indicates the server was unable to discover // a complete list of APIs for the client to use. func IsGroupDiscoveryFailedError(err error) bool { From 1863a808b2082ddd8d116e6b31fd41de412e8a20 Mon Sep 17 00:00:00 2001 From: Tarun Gupta Akirala Date: Thu, 10 Aug 2023 10:50:01 -0700 Subject: [PATCH 2/2] fix: add code comments --- staging/src/k8s.io/client-go/discovery/discovery_client.go | 1 + 1 file changed, 1 insertion(+) diff --git a/staging/src/k8s.io/client-go/discovery/discovery_client.go b/staging/src/k8s.io/client-go/discovery/discovery_client.go index a6c6718246e..dc4432939f8 100644 --- a/staging/src/k8s.io/client-go/discovery/discovery_client.go +++ b/staging/src/k8s.io/client-go/discovery/discovery_client.go @@ -415,6 +415,7 @@ func (e *ErrGroupDiscoveryFailed) Error() string { return fmt.Sprintf("unable to retrieve the complete list of server APIs: %s", strings.Join(groups, ", ")) } +// Is makes it possible for the callers to use `errors.Is(` helper on errors wrapped with ErrGroupDiscoveryFailed error. func (e *ErrGroupDiscoveryFailed) Is(target error) bool { _, ok := target.(*ErrGroupDiscoveryFailed) return ok