Skip to content

Commit

Permalink
Handle the case when namespace do not exists as a resource in the clu… (
Browse files Browse the repository at this point in the history
#269)

* Handle the case when namespace do not exists as a resource in the cluster

* code review comments

* provide default namespace as ucp resources are namespaced ones

---------

Co-authored-by: Atanas Todorov <[email protected]>
  • Loading branch information
nasioman and Atanas Todorov authored Jan 10, 2025
1 parent 3ac3086 commit 45f6258
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion k8s/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package k8s
import (
"context"
"fmt"
"k8s.io/apimachinery/pkg/api/errors"
"strings"

"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -225,7 +226,12 @@ func (k8sc *Client) _search(ctx context.Context, groups, categories, kinds, name
} else {
nsNames, err := getNamespaces(ctx, k8sc)
if err != nil {
return nil, err
if !errors.IsNotFound(err) {
return nil, err
}
//This is the case when namespace resource does not exist in the cluster.This is KCP case.
//Continue the execution of this function with emtpy namespace list
nsNames = append(nsNames, "default")
}
nsList = nsNames
}
Expand Down

0 comments on commit 45f6258

Please sign in to comment.