Skip to content

Commit

Permalink
Rename fileter.go to objectutil.go
Browse files Browse the repository at this point in the history
Signed-off-by: varshaprasad96 <[email protected]>
  • Loading branch information
varshaprasad96 committed Apr 26, 2021
1 parent 6a42f89 commit f10a6b5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions pkg/cache/multi_namespace_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
type NewCacheFunc func(config *rest.Config, opts Options) (Cache, error)

// a new global namespaced cache to handle cluster scoped resources
var globalCache = "cluster-scope"
var globalCache = "_cluster-scope"

// MultiNamespacedCacheBuilder - Builder function to create a new multi-namespaced cache.
// This will scope the cache to a list of namespaces. Listing for all namespaces
Expand Down Expand Up @@ -135,7 +135,7 @@ func (c *multiNamespaceCache) IndexField(ctx context.Context, obj client.Object,
}

func (c *multiNamespaceCache) Get(ctx context.Context, key client.ObjectKey, obj client.Object) error {
isNamespaced, err := objectutil.IsNamespacedObject(obj, c.Scheme, c.RESTMapper)
isNamespaced, err := objectutil.IsAPINamespaced(obj, c.Scheme, c.RESTMapper)
if err != nil {
return err
}
Expand All @@ -158,7 +158,7 @@ func (c *multiNamespaceCache) List(ctx context.Context, list client.ObjectList,
listOpts := client.ListOptions{}
listOpts.ApplyOptions(opts)

isNamespaced, err := objectutil.IsNamespacedObject(list, c.Scheme, c.RESTMapper)
isNamespaced, err := objectutil.IsAPINamespaced(list, c.Scheme, c.RESTMapper)
if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions pkg/client/namespaced_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (n *namespacedClient) RESTMapper() meta.RESTMapper {

// isNamespaced returns true if the object is namespace scoped.
// For unstructured objects the gvk is found from the object itself.
// TODO: this is repetitive code. Remove this and use ojectutil.IsNamespaced.
func isNamespaced(c Client, obj runtime.Object) (bool, error) {
var gvk schema.GroupVersionKind
var err error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ func FilterWithLabels(objs []runtime.Object, labelSel labels.Selector) ([]runtim
return outItems, nil
}

// IsNamespacedObject returns true if the object is namespace scoped.
// IsAPINamespaced returns true if the object is namespace scoped.
// For unstructured objects the gvk is found from the object itself.
func IsNamespacedObject(obj runtime.Object, scheme *runtime.Scheme, restmapper apimeta.RESTMapper) (bool, error) {
func IsAPINamespaced(obj runtime.Object, scheme *runtime.Scheme, restmapper apimeta.RESTMapper) (bool, error) {
var gvk schema.GroupVersionKind
var err error

Expand Down

0 comments on commit f10a6b5

Please sign in to comment.