From f32ea23c9d810cbdb698e74d06db0769c05e5284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?= Date: Wed, 27 Apr 2022 15:14:49 +0200 Subject: [PATCH] chore: remove unused custom expansions from client (#3697) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles-Edouard Brétéché --- .../kyverno/v1/clusterpolicy_expansion.go | 18 -------- .../listers/kyverno/v1/expansion_generated.go | 12 +++++ .../kyverno/v1/generaterequest_expansion.go | 44 ------------------- 3 files changed, 12 insertions(+), 62 deletions(-) delete mode 100644 pkg/client/listers/kyverno/v1/clusterpolicy_expansion.go delete mode 100644 pkg/client/listers/kyverno/v1/generaterequest_expansion.go diff --git a/pkg/client/listers/kyverno/v1/clusterpolicy_expansion.go b/pkg/client/listers/kyverno/v1/clusterpolicy_expansion.go deleted file mode 100644 index 69f9f4a918..0000000000 --- a/pkg/client/listers/kyverno/v1/clusterpolicy_expansion.go +++ /dev/null @@ -1,18 +0,0 @@ -package v1 - -import ( - v1 "github.com/kyverno/kyverno/api/kyverno/v1" - "k8s.io/apimachinery/pkg/labels" -) - -type ClusterPolicyListerExpansion interface{} - -//ListResources is a wrapper to List and adds the resource kind information -// as the lister is specific to a gvk we can harcode the values here -func (pl *clusterPolicyLister) ListResources(selector labels.Selector) (ret []*v1.ClusterPolicy, err error) { - policies, err := pl.List(selector) - for index := range policies { - policies[index].SetGroupVersionKind(v1.SchemeGroupVersion.WithKind("ClusterPolicy")) - } - return policies, err -} diff --git a/pkg/client/listers/kyverno/v1/expansion_generated.go b/pkg/client/listers/kyverno/v1/expansion_generated.go index fa4dad5fa2..26bce92110 100644 --- a/pkg/client/listers/kyverno/v1/expansion_generated.go +++ b/pkg/client/listers/kyverno/v1/expansion_generated.go @@ -18,6 +18,18 @@ limitations under the License. package v1 +// ClusterPolicyListerExpansion allows custom methods to be added to +// ClusterPolicyLister. +type ClusterPolicyListerExpansion interface{} + +// GenerateRequestListerExpansion allows custom methods to be added to +// GenerateRequestLister. +type GenerateRequestListerExpansion interface{} + +// GenerateRequestNamespaceListerExpansion allows custom methods to be added to +// GenerateRequestNamespaceLister. +type GenerateRequestNamespaceListerExpansion interface{} + // PolicyListerExpansion allows custom methods to be added to // PolicyLister. type PolicyListerExpansion interface{} diff --git a/pkg/client/listers/kyverno/v1/generaterequest_expansion.go b/pkg/client/listers/kyverno/v1/generaterequest_expansion.go deleted file mode 100644 index 612fc9c541..0000000000 --- a/pkg/client/listers/kyverno/v1/generaterequest_expansion.go +++ /dev/null @@ -1,44 +0,0 @@ -package v1 - -import ( - v1 "github.com/kyverno/kyverno/api/kyverno/v1" - "k8s.io/apimachinery/pkg/labels" -) - -type GenerateRequestListerExpansion interface{} - -type GenerateRequestNamespaceListerExpansion interface { - GetGenerateRequestsForClusterPolicy(policy string) ([]*v1.GenerateRequest, error) - GetGenerateRequestsForResource(kind, namespace, name string) ([]*v1.GenerateRequest, error) -} - -func (s generateRequestNamespaceLister) GetGenerateRequestsForResource(kind, namespace, name string) ([]*v1.GenerateRequest, error) { - var list []*v1.GenerateRequest - grs, err := s.List(labels.NewSelector()) - if err != nil { - return nil, err - } - for idx, gr := range grs { - if gr.Spec.Resource.Kind == kind && - gr.Spec.Resource.Namespace == namespace && - gr.Spec.Resource.Name == name { - list = append(list, grs[idx]) - - } - } - return list, err -} - -func (s generateRequestNamespaceLister) GetGenerateRequestsForClusterPolicy(policy string) ([]*v1.GenerateRequest, error) { - var list []*v1.GenerateRequest - grs, err := s.List(labels.NewSelector()) - if err != nil { - return nil, err - } - for idx, gr := range grs { - if gr.Spec.Policy == policy { - list = append(list, grs[idx]) - } - } - return list, err -}