Skip to content

Commit

Permalink
fix: Fix error returned by lazy rest mapper.
Browse files Browse the repository at this point in the history
Signed-off-by: Andrej Krejcir <[email protected]>
  • Loading branch information
akrejcir committed Dec 1, 2023
1 parent 8bf4bfe commit cb459dd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/common/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package common

import (
"context"
"errors"
"fmt"
"os"
"strings"
Expand All @@ -12,6 +13,7 @@ import (
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/discovery"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand Down Expand Up @@ -63,8 +65,9 @@ func RunningOnOpenshift(ctx context.Context, cl client.Reader) (bool, error) {
Name: "version",
},
}
if err := cl.Get(ctx, client.ObjectKeyFromObject(clusterVersion), clusterVersion); err != nil {
if meta.IsNoMatchError(err) || apierrors.IsNotFound(err) {
err := cl.Get(ctx, client.ObjectKeyFromObject(clusterVersion), clusterVersion)
if err != nil {
if meta.IsNoMatchError(err) || apierrors.IsNotFound(err) || errors.Is(err, &discovery.ErrGroupDiscoveryFailed{}) {
// Not on OpenShift
return false, nil
} else {
Expand Down

0 comments on commit cb459dd

Please sign in to comment.