mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-13 19:28:55 +00:00
fix: remove obsolete methode in discovery (#7802)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
parent
eb4b8614f0
commit
dfceb4bf82
5 changed files with 9 additions and 19 deletions
|
@ -49,8 +49,7 @@ type IDiscovery interface {
|
|||
GetGVRFromGVK(schema.GroupVersionKind) (schema.GroupVersionResource, error)
|
||||
GetGVKFromGVR(schema.GroupVersionResource) (schema.GroupVersionKind, error)
|
||||
OpenAPISchema() (*openapiv2.Document, error)
|
||||
DiscoveryCache() discovery.CachedDiscoveryInterface
|
||||
DiscoveryInterface() discovery.DiscoveryInterface
|
||||
CachedDiscoveryInterface() discovery.CachedDiscoveryInterface
|
||||
}
|
||||
|
||||
// apiResourceWithListGV is a wrapper for metav1.APIResource with the group-version of its metav1.APIResourceList
|
||||
|
@ -64,13 +63,8 @@ type serverResources struct {
|
|||
cachedClient discovery.CachedDiscoveryInterface
|
||||
}
|
||||
|
||||
// DiscoveryCache gets the discovery client cache
|
||||
func (c serverResources) DiscoveryCache() discovery.CachedDiscoveryInterface {
|
||||
return c.cachedClient
|
||||
}
|
||||
|
||||
// DiscoveryInterface gets the discovery client
|
||||
func (c serverResources) DiscoveryInterface() discovery.DiscoveryInterface {
|
||||
// CachedDiscoveryInterface gets the discovery client cache
|
||||
func (c serverResources) CachedDiscoveryInterface() discovery.CachedDiscoveryInterface {
|
||||
return c.cachedClient
|
||||
}
|
||||
|
||||
|
|
|
@ -98,10 +98,6 @@ func (c *fakeDiscoveryClient) OpenAPISchema() (*openapiv2.Document, error) {
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *fakeDiscoveryClient) DiscoveryCache() discovery.CachedDiscoveryInterface {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *fakeDiscoveryClient) DiscoveryInterface() discovery.DiscoveryInterface {
|
||||
func (c *fakeDiscoveryClient) CachedDiscoveryInterface() discovery.CachedDiscoveryInterface {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ func (c *controller) Run(ctx context.Context, workers int) {
|
|||
func (c *controller) sync() {
|
||||
c.manager.Lock()
|
||||
defer c.manager.Unlock()
|
||||
c.client.Discovery().DiscoveryCache().Invalidate()
|
||||
c.client.Discovery().CachedDiscoveryInterface().Invalidate()
|
||||
crds, err := c.client.GetDynamicInterface().Resource(runtimeSchema.GroupVersionResource{
|
||||
Group: "apiextensions.k8s.io",
|
||||
Version: "v1",
|
||||
|
@ -108,7 +108,7 @@ func (c *controller) sync() {
|
|||
|
||||
func (c *controller) updateInClusterKindToAPIVersions() error {
|
||||
overrideRuntimeErrorHandler()
|
||||
_, apiResourceLists, err := discovery.ServerGroupsAndResources(c.client.Discovery().DiscoveryInterface())
|
||||
_, apiResourceLists, err := discovery.ServerGroupsAndResources(c.client.Discovery().CachedDiscoveryInterface())
|
||||
if err != nil {
|
||||
if discovery.IsGroupDiscoveryFailedError(err) {
|
||||
err := err.(*discovery.ErrGroupDiscoveryFailed)
|
||||
|
@ -119,7 +119,7 @@ func (c *controller) updateInClusterKindToAPIVersions() error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
preferredAPIResourcesLists, err := discovery.ServerPreferredResources(c.client.Discovery().DiscoveryInterface())
|
||||
preferredAPIResourcesLists, err := discovery.ServerPreferredResources(c.client.Discovery().CachedDiscoveryInterface())
|
||||
if err != nil {
|
||||
if discovery.IsGroupDiscoveryFailedError(err) {
|
||||
err := err.(*discovery.ErrGroupDiscoveryFailed)
|
||||
|
|
|
@ -18,7 +18,7 @@ import (
|
|||
|
||||
// FetchClusteredResources retieves the list of clustered resources
|
||||
func FetchClusteredResources(logger logr.Logger, client dclient.Interface) (sets.Set[string], error) {
|
||||
res, err := discovery.ServerPreferredResources(client.Discovery().DiscoveryInterface())
|
||||
res, err := discovery.ServerPreferredResources(client.Discovery().CachedDiscoveryInterface())
|
||||
if err != nil {
|
||||
if discovery.IsGroupDiscoveryFailedError(err) {
|
||||
err := err.(*discovery.ErrGroupDiscoveryFailed)
|
||||
|
|
|
@ -149,7 +149,7 @@ func Validate(policy, oldPolicy kyvernov1.PolicyInterface, client dclient.Interf
|
|||
clusterResources := sets.New[string]()
|
||||
if !mock {
|
||||
// Get all the cluster type kind supported by cluster
|
||||
res, err = discovery.ServerPreferredResources(client.Discovery().DiscoveryInterface())
|
||||
res, err = discovery.ServerPreferredResources(client.Discovery().CachedDiscoveryInterface())
|
||||
if err != nil {
|
||||
if discovery.IsGroupDiscoveryFailedError(err) {
|
||||
err := err.(*discovery.ErrGroupDiscoveryFailed)
|
||||
|
|
Loading…
Add table
Reference in a new issue