From 2d0d0ecd9df32a03710cf4aff225ab76f3a296f6 Mon Sep 17 00:00:00 2001 From: Matheus Moraes Date: Mon, 22 Apr 2024 14:17:42 -0300 Subject: [PATCH] Fix clientset generation and add for informers and listers (#275) * fix generate-client Makefile target * add SchemeGroupVersion var in v1alpha2 package * add Resource function in v1alpha1 and v1alpha2 packages * add +genclient directive in all APIs * generate clientset, informers, and listers --- Makefile | 16 +- api/zora/v1alpha1/cluster_types.go | 2 - api/zora/v1alpha1/clusterissue_types.go | 1 - api/zora/v1alpha1/clusterscan_types.go | 2 - api/zora/v1alpha1/customcheck_types.go | 1 + api/zora/v1alpha1/groupversion_info.go | 5 + api/zora/v1alpha1/plugin_types.go | 1 + .../v1alpha1/vulnerabilityreport_types.go | 1 - api/zora/v1alpha2/customcheck_types.go | 1 + api/zora/v1alpha2/groupversion_info.go | 8 + pkg/clientset/versioned/clientset.go | 13 + .../versioned/fake/clientset_generated.go | 7 + pkg/clientset/versioned/fake/register.go | 2 + pkg/clientset/versioned/scheme/register.go | 2 + .../versioned/typed/zora/v1alpha1/cluster.go | 109 ++++++++ .../typed/zora/v1alpha1/clusterissue.go | 17 ++ .../typed/zora/v1alpha1/clusterscan.go | 109 ++++++++ .../typed/zora/v1alpha1/customcheck.go | 179 +++++++++++++ .../typed/zora/v1alpha1/fake/fake_cluster.go | 70 +++++ .../zora/v1alpha1/fake/fake_clusterissue.go | 12 + .../zora/v1alpha1/fake/fake_clusterscan.go | 70 +++++ .../zora/v1alpha1/fake/fake_customcheck.go | 125 +++++++++ .../typed/zora/v1alpha1/fake/fake_plugin.go | 125 +++++++++ .../v1alpha1/fake/fake_vulnerabilityreport.go | 12 + .../zora/v1alpha1/fake/fake_zora_client.go | 8 + .../zora/v1alpha1/generated_expansion.go | 4 + .../versioned/typed/zora/v1alpha1/plugin.go | 179 +++++++++++++ .../zora/v1alpha1/vulnerabilityreport.go | 17 ++ .../typed/zora/v1alpha1/zora_client.go | 10 + .../typed/zora/v1alpha2/customcheck.go | 179 +++++++++++++ .../versioned/typed/zora/v1alpha2/doc.go | 4 + .../versioned/typed/zora/v1alpha2/fake/doc.go | 4 + .../zora/v1alpha2/fake/fake_customcheck.go | 125 +++++++++ .../zora/v1alpha2/fake/fake_zora_client.go | 24 ++ .../zora/v1alpha2/generated_expansion.go | 5 + .../typed/zora/v1alpha2/zora_client.go | 91 +++++++ pkg/informers/externalversions/factory.go | 245 ++++++++++++++++++ pkg/informers/externalversions/generic.go | 61 +++++ .../internalinterfaces/factory_interfaces.go | 24 ++ .../externalversions/zora/interface.go | 38 +++ .../externalversions/zora/v1alpha1/cluster.go | 74 ++++++ .../zora/v1alpha1/clusterissue.go | 74 ++++++ .../zora/v1alpha1/clusterscan.go | 74 ++++++ .../zora/v1alpha1/customcheck.go | 74 ++++++ .../zora/v1alpha1/interface.go | 64 +++++ .../externalversions/zora/v1alpha1/plugin.go | 74 ++++++ .../zora/v1alpha1/vulnerabilityreport.go | 74 ++++++ .../zora/v1alpha2/customcheck.go | 74 ++++++ .../zora/v1alpha2/interface.go | 29 +++ pkg/listers/zora/v1alpha1/cluster.go | 83 ++++++ pkg/listers/zora/v1alpha1/clusterissue.go | 83 ++++++ pkg/listers/zora/v1alpha1/clusterscan.go | 83 ++++++ pkg/listers/zora/v1alpha1/customcheck.go | 83 ++++++ .../zora/v1alpha1/expansion_generated.go | 51 ++++ pkg/listers/zora/v1alpha1/plugin.go | 83 ++++++ .../zora/v1alpha1/vulnerabilityreport.go | 83 ++++++ pkg/listers/zora/v1alpha2/customcheck.go | 83 ++++++ .../zora/v1alpha2/expansion_generated.go | 11 + 58 files changed, 3146 insertions(+), 16 deletions(-) create mode 100644 pkg/clientset/versioned/typed/zora/v1alpha1/customcheck.go create mode 100644 pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_customcheck.go create mode 100644 pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_plugin.go create mode 100644 pkg/clientset/versioned/typed/zora/v1alpha1/plugin.go create mode 100644 pkg/clientset/versioned/typed/zora/v1alpha2/customcheck.go create mode 100644 pkg/clientset/versioned/typed/zora/v1alpha2/doc.go create mode 100644 pkg/clientset/versioned/typed/zora/v1alpha2/fake/doc.go create mode 100644 pkg/clientset/versioned/typed/zora/v1alpha2/fake/fake_customcheck.go create mode 100644 pkg/clientset/versioned/typed/zora/v1alpha2/fake/fake_zora_client.go create mode 100644 pkg/clientset/versioned/typed/zora/v1alpha2/generated_expansion.go create mode 100644 pkg/clientset/versioned/typed/zora/v1alpha2/zora_client.go create mode 100644 pkg/informers/externalversions/factory.go create mode 100644 pkg/informers/externalversions/generic.go create mode 100644 pkg/informers/externalversions/internalinterfaces/factory_interfaces.go create mode 100644 pkg/informers/externalversions/zora/interface.go create mode 100644 pkg/informers/externalversions/zora/v1alpha1/cluster.go create mode 100644 pkg/informers/externalversions/zora/v1alpha1/clusterissue.go create mode 100644 pkg/informers/externalversions/zora/v1alpha1/clusterscan.go create mode 100644 pkg/informers/externalversions/zora/v1alpha1/customcheck.go create mode 100644 pkg/informers/externalversions/zora/v1alpha1/interface.go create mode 100644 pkg/informers/externalversions/zora/v1alpha1/plugin.go create mode 100644 pkg/informers/externalversions/zora/v1alpha1/vulnerabilityreport.go create mode 100644 pkg/informers/externalversions/zora/v1alpha2/customcheck.go create mode 100644 pkg/informers/externalversions/zora/v1alpha2/interface.go create mode 100644 pkg/listers/zora/v1alpha1/cluster.go create mode 100644 pkg/listers/zora/v1alpha1/clusterissue.go create mode 100644 pkg/listers/zora/v1alpha1/clusterscan.go create mode 100644 pkg/listers/zora/v1alpha1/customcheck.go create mode 100644 pkg/listers/zora/v1alpha1/expansion_generated.go create mode 100644 pkg/listers/zora/v1alpha1/plugin.go create mode 100644 pkg/listers/zora/v1alpha1/vulnerabilityreport.go create mode 100644 pkg/listers/zora/v1alpha2/customcheck.go create mode 100644 pkg/listers/zora/v1alpha2/expansion_generated.go diff --git a/Makefile b/Makefile index 9881c3e0..9396bf78 100644 --- a/Makefile +++ b/Makefile @@ -55,19 +55,15 @@ manifests: controller-gen addlicense ## Generate WebhookConfiguration, ClusterRo generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." -PROJECT_PACKAGE ?= $(shell go list -m) .PHONY: generate-client generate-client: ## Generate client - @rm -r pkg/clientset || echo -n + @rm -r pkg/clientset pkg/informers pkg/listers || echo -n $(CONTAINER_TOOL) run -i --rm \ - -v $(PWD):/go/src/$(PROJECT_PACKAGE) \ - -e PROJECT_PACKAGE=$(PROJECT_PACKAGE) \ - -e CLIENT_GENERATOR_OUT=$(PROJECT_PACKAGE)/pkg \ - -e APIS_ROOT=$(PROJECT_PACKAGE)/api \ - -e GROUPS_VERSION="zora:v1alpha1" \ - -e GENERATION_TARGETS="client" \ - -e BOILERPLATE_PATH="hack/boilerplate.go.txt" \ - ghcr.io/slok/kube-code-generator:v0.1.0 + -v $(PWD):/app \ + ghcr.io/slok/kube-code-generator:v0.1.0 \ + --apis-in ./api \ + --go-gen-out ./pkg \ + --debug .PHONY: generate-helm-docs generate-helm-docs: helm-docs ## Generate documentation for helm chart. diff --git a/api/zora/v1alpha1/cluster_types.go b/api/zora/v1alpha1/cluster_types.go index c312517e..ef33fbb6 100644 --- a/api/zora/v1alpha1/cluster_types.go +++ b/api/zora/v1alpha1/cluster_types.go @@ -92,8 +92,6 @@ func (in *ClusterStatus) SetResources(res discovery.ClusterResources) { // Cluster is the Schema for the clusters API // +genclient -// +genclient:onlyVerbs=list,get -// +genclient:noStatus type Cluster struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` diff --git a/api/zora/v1alpha1/clusterissue_types.go b/api/zora/v1alpha1/clusterissue_types.go index 8bb01881..f10f3186 100644 --- a/api/zora/v1alpha1/clusterissue_types.go +++ b/api/zora/v1alpha1/clusterissue_types.go @@ -81,7 +81,6 @@ type ClusterIssueStatus struct { // ClusterIssue is the Schema for the clusterissues API // +genclient -// +genclient:noStatus type ClusterIssue struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` diff --git a/api/zora/v1alpha1/clusterscan_types.go b/api/zora/v1alpha1/clusterscan_types.go index ecb2f559..22eff7d6 100644 --- a/api/zora/v1alpha1/clusterscan_types.go +++ b/api/zora/v1alpha1/clusterscan_types.go @@ -273,8 +273,6 @@ type PluginScanStatus struct { // ClusterScan is the Schema for the clusterscans API // +genclient -// +genclient:onlyVerbs=list,get -// +genclient:noStatus type ClusterScan struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` diff --git a/api/zora/v1alpha1/customcheck_types.go b/api/zora/v1alpha1/customcheck_types.go index b60bc78a..2afb1139 100644 --- a/api/zora/v1alpha1/customcheck_types.go +++ b/api/zora/v1alpha1/customcheck_types.go @@ -53,6 +53,7 @@ type CustomCheckStatus struct { //+kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",priority=0 // CustomCheck is the Schema for the customchecks API +// +genclient type CustomCheck struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` diff --git a/api/zora/v1alpha1/groupversion_info.go b/api/zora/v1alpha1/groupversion_info.go index 8fdeedbc..de8d718f 100644 --- a/api/zora/v1alpha1/groupversion_info.go +++ b/api/zora/v1alpha1/groupversion_info.go @@ -35,3 +35,8 @@ var ( // AddToScheme adds the types in this group-version to the given scheme. AddToScheme = SchemeBuilder.AddToScheme ) + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} diff --git a/api/zora/v1alpha1/plugin_types.go b/api/zora/v1alpha1/plugin_types.go index adaffe74..569e83ab 100644 --- a/api/zora/v1alpha1/plugin_types.go +++ b/api/zora/v1alpha1/plugin_types.go @@ -106,6 +106,7 @@ type PluginStatus struct { //+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" // Plugin is the Schema for the plugins API +// +genclient type Plugin struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` diff --git a/api/zora/v1alpha1/vulnerabilityreport_types.go b/api/zora/v1alpha1/vulnerabilityreport_types.go index 4f368b2d..008747e7 100644 --- a/api/zora/v1alpha1/vulnerabilityreport_types.go +++ b/api/zora/v1alpha1/vulnerabilityreport_types.go @@ -100,7 +100,6 @@ func (in *VulnerabilityReport) SaaSStatusIsTrue() bool { // VulnerabilityReport is the Schema for the vulnerabilityreports API // +genclient -// +genclient:noStatus type VulnerabilityReport struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` diff --git a/api/zora/v1alpha2/customcheck_types.go b/api/zora/v1alpha2/customcheck_types.go index 0ec20063..e402e075 100644 --- a/api/zora/v1alpha2/customcheck_types.go +++ b/api/zora/v1alpha2/customcheck_types.go @@ -46,6 +46,7 @@ type CustomCheckStatus struct { //+kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",priority=0 // CustomCheck is the Schema for the customchecks API +// +genclient type CustomCheck struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` diff --git a/api/zora/v1alpha2/groupversion_info.go b/api/zora/v1alpha2/groupversion_info.go index e5d44b5d..3fa27c77 100644 --- a/api/zora/v1alpha2/groupversion_info.go +++ b/api/zora/v1alpha2/groupversion_info.go @@ -26,9 +26,17 @@ var ( // GroupVersion is group version used to register these objects GroupVersion = schema.GroupVersion{Group: "zora.undistro.io", Version: "v1alpha2"} + // SchemeGroupVersion is a copy of GroupVersion, used by client-gen + SchemeGroupVersion = GroupVersion + // SchemeBuilder is used to add go types to the GroupVersionKind scheme SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} // AddToScheme adds the types in this group-version to the given scheme. AddToScheme = SchemeBuilder.AddToScheme ) + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} diff --git a/pkg/clientset/versioned/clientset.go b/pkg/clientset/versioned/clientset.go index c0e70d75..e27f0467 100644 --- a/pkg/clientset/versioned/clientset.go +++ b/pkg/clientset/versioned/clientset.go @@ -7,6 +7,7 @@ import ( "net/http" zorav1alpha1 "github.com/undistro/zora/pkg/clientset/versioned/typed/zora/v1alpha1" + zorav1alpha2 "github.com/undistro/zora/pkg/clientset/versioned/typed/zora/v1alpha2" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" @@ -15,12 +16,14 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface ZoraV1alpha1() zorav1alpha1.ZoraV1alpha1Interface + ZoraV1alpha2() zorav1alpha2.ZoraV1alpha2Interface } // Clientset contains the clients for groups. type Clientset struct { *discovery.DiscoveryClient zoraV1alpha1 *zorav1alpha1.ZoraV1alpha1Client + zoraV1alpha2 *zorav1alpha2.ZoraV1alpha2Client } // ZoraV1alpha1 retrieves the ZoraV1alpha1Client @@ -28,6 +31,11 @@ func (c *Clientset) ZoraV1alpha1() zorav1alpha1.ZoraV1alpha1Interface { return c.zoraV1alpha1 } +// ZoraV1alpha2 retrieves the ZoraV1alpha2Client +func (c *Clientset) ZoraV1alpha2() zorav1alpha2.ZoraV1alpha2Interface { + return c.zoraV1alpha2 +} + // Discovery retrieves the DiscoveryClient func (c *Clientset) Discovery() discovery.DiscoveryInterface { if c == nil { @@ -76,6 +84,10 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, if err != nil { return nil, err } + cs.zoraV1alpha2, err = zorav1alpha2.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) if err != nil { @@ -98,6 +110,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { func New(c rest.Interface) *Clientset { var cs Clientset cs.zoraV1alpha1 = zorav1alpha1.New(c) + cs.zoraV1alpha2 = zorav1alpha2.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/pkg/clientset/versioned/fake/clientset_generated.go b/pkg/clientset/versioned/fake/clientset_generated.go index 8af76585..79f313d6 100644 --- a/pkg/clientset/versioned/fake/clientset_generated.go +++ b/pkg/clientset/versioned/fake/clientset_generated.go @@ -6,6 +6,8 @@ import ( clientset "github.com/undistro/zora/pkg/clientset/versioned" zorav1alpha1 "github.com/undistro/zora/pkg/clientset/versioned/typed/zora/v1alpha1" fakezorav1alpha1 "github.com/undistro/zora/pkg/clientset/versioned/typed/zora/v1alpha1/fake" + zorav1alpha2 "github.com/undistro/zora/pkg/clientset/versioned/typed/zora/v1alpha2" + fakezorav1alpha2 "github.com/undistro/zora/pkg/clientset/versioned/typed/zora/v1alpha2/fake" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/discovery" @@ -67,3 +69,8 @@ var ( func (c *Clientset) ZoraV1alpha1() zorav1alpha1.ZoraV1alpha1Interface { return &fakezorav1alpha1.FakeZoraV1alpha1{Fake: &c.Fake} } + +// ZoraV1alpha2 retrieves the ZoraV1alpha2Client +func (c *Clientset) ZoraV1alpha2() zorav1alpha2.ZoraV1alpha2Interface { + return &fakezorav1alpha2.FakeZoraV1alpha2{Fake: &c.Fake} +} diff --git a/pkg/clientset/versioned/fake/register.go b/pkg/clientset/versioned/fake/register.go index 8c64b331..44a53182 100644 --- a/pkg/clientset/versioned/fake/register.go +++ b/pkg/clientset/versioned/fake/register.go @@ -4,6 +4,7 @@ package fake import ( zorav1alpha1 "github.com/undistro/zora/api/zora/v1alpha1" + zorav1alpha2 "github.com/undistro/zora/api/zora/v1alpha2" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -16,6 +17,7 @@ var codecs = serializer.NewCodecFactory(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ zorav1alpha1.AddToScheme, + zorav1alpha2.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/clientset/versioned/scheme/register.go b/pkg/clientset/versioned/scheme/register.go index 9c8d6d65..a258e681 100644 --- a/pkg/clientset/versioned/scheme/register.go +++ b/pkg/clientset/versioned/scheme/register.go @@ -4,6 +4,7 @@ package scheme import ( zorav1alpha1 "github.com/undistro/zora/api/zora/v1alpha1" + zorav1alpha2 "github.com/undistro/zora/api/zora/v1alpha2" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -16,6 +17,7 @@ var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ zorav1alpha1.AddToScheme, + zorav1alpha2.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/clientset/versioned/typed/zora/v1alpha1/cluster.go b/pkg/clientset/versioned/typed/zora/v1alpha1/cluster.go index 505d1ad3..af1dc3cf 100644 --- a/pkg/clientset/versioned/typed/zora/v1alpha1/cluster.go +++ b/pkg/clientset/versioned/typed/zora/v1alpha1/cluster.go @@ -9,6 +9,8 @@ import ( v1alpha1 "github.com/undistro/zora/api/zora/v1alpha1" scheme "github.com/undistro/zora/pkg/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" ) @@ -20,8 +22,15 @@ type ClustersGetter interface { // ClusterInterface has methods to work with Cluster resources. type ClusterInterface interface { + Create(ctx context.Context, cluster *v1alpha1.Cluster, opts v1.CreateOptions) (*v1alpha1.Cluster, error) + Update(ctx context.Context, cluster *v1alpha1.Cluster, opts v1.UpdateOptions) (*v1alpha1.Cluster, error) + UpdateStatus(ctx context.Context, cluster *v1alpha1.Cluster, opts v1.UpdateOptions) (*v1alpha1.Cluster, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.Cluster, error) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ClusterList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Cluster, err error) ClusterExpansion } @@ -68,3 +77,103 @@ func (c *clusters) List(ctx context.Context, opts v1.ListOptions) (result *v1alp Into(result) return } + +// Watch returns a watch.Interface that watches the requested clusters. +func (c *clusters) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("clusters"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a cluster and creates it. Returns the server's representation of the cluster, and an error, if there is any. +func (c *clusters) Create(ctx context.Context, cluster *v1alpha1.Cluster, opts v1.CreateOptions) (result *v1alpha1.Cluster, err error) { + result = &v1alpha1.Cluster{} + err = c.client.Post(). + Namespace(c.ns). + Resource("clusters"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(cluster). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a cluster and updates it. Returns the server's representation of the cluster, and an error, if there is any. +func (c *clusters) Update(ctx context.Context, cluster *v1alpha1.Cluster, opts v1.UpdateOptions) (result *v1alpha1.Cluster, err error) { + result = &v1alpha1.Cluster{} + err = c.client.Put(). + Namespace(c.ns). + Resource("clusters"). + Name(cluster.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(cluster). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *clusters) UpdateStatus(ctx context.Context, cluster *v1alpha1.Cluster, opts v1.UpdateOptions) (result *v1alpha1.Cluster, err error) { + result = &v1alpha1.Cluster{} + err = c.client.Put(). + Namespace(c.ns). + Resource("clusters"). + Name(cluster.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(cluster). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the cluster and deletes it. Returns an error if one occurs. +func (c *clusters) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("clusters"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *clusters) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("clusters"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched cluster. +func (c *clusters) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Cluster, err error) { + result = &v1alpha1.Cluster{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("clusters"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/clientset/versioned/typed/zora/v1alpha1/clusterissue.go b/pkg/clientset/versioned/typed/zora/v1alpha1/clusterissue.go index 2e4bb89f..62dc3876 100644 --- a/pkg/clientset/versioned/typed/zora/v1alpha1/clusterissue.go +++ b/pkg/clientset/versioned/typed/zora/v1alpha1/clusterissue.go @@ -24,6 +24,7 @@ type ClusterIssuesGetter interface { type ClusterIssueInterface interface { Create(ctx context.Context, clusterIssue *v1alpha1.ClusterIssue, opts v1.CreateOptions) (*v1alpha1.ClusterIssue, error) Update(ctx context.Context, clusterIssue *v1alpha1.ClusterIssue, opts v1.UpdateOptions) (*v1alpha1.ClusterIssue, error) + UpdateStatus(ctx context.Context, clusterIssue *v1alpha1.ClusterIssue, opts v1.UpdateOptions) (*v1alpha1.ClusterIssue, error) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.ClusterIssue, error) @@ -119,6 +120,22 @@ func (c *clusterIssues) Update(ctx context.Context, clusterIssue *v1alpha1.Clust return } +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *clusterIssues) UpdateStatus(ctx context.Context, clusterIssue *v1alpha1.ClusterIssue, opts v1.UpdateOptions) (result *v1alpha1.ClusterIssue, err error) { + result = &v1alpha1.ClusterIssue{} + err = c.client.Put(). + Namespace(c.ns). + Resource("clusterissues"). + Name(clusterIssue.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(clusterIssue). + Do(ctx). + Into(result) + return +} + // Delete takes name of the clusterIssue and deletes it. Returns an error if one occurs. func (c *clusterIssues) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { return c.client.Delete(). diff --git a/pkg/clientset/versioned/typed/zora/v1alpha1/clusterscan.go b/pkg/clientset/versioned/typed/zora/v1alpha1/clusterscan.go index 9066ee9f..a9eb4bfe 100644 --- a/pkg/clientset/versioned/typed/zora/v1alpha1/clusterscan.go +++ b/pkg/clientset/versioned/typed/zora/v1alpha1/clusterscan.go @@ -9,6 +9,8 @@ import ( v1alpha1 "github.com/undistro/zora/api/zora/v1alpha1" scheme "github.com/undistro/zora/pkg/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" ) @@ -20,8 +22,15 @@ type ClusterScansGetter interface { // ClusterScanInterface has methods to work with ClusterScan resources. type ClusterScanInterface interface { + Create(ctx context.Context, clusterScan *v1alpha1.ClusterScan, opts v1.CreateOptions) (*v1alpha1.ClusterScan, error) + Update(ctx context.Context, clusterScan *v1alpha1.ClusterScan, opts v1.UpdateOptions) (*v1alpha1.ClusterScan, error) + UpdateStatus(ctx context.Context, clusterScan *v1alpha1.ClusterScan, opts v1.UpdateOptions) (*v1alpha1.ClusterScan, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.ClusterScan, error) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ClusterScanList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ClusterScan, err error) ClusterScanExpansion } @@ -68,3 +77,103 @@ func (c *clusterScans) List(ctx context.Context, opts v1.ListOptions) (result *v Into(result) return } + +// Watch returns a watch.Interface that watches the requested clusterScans. +func (c *clusterScans) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("clusterscans"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a clusterScan and creates it. Returns the server's representation of the clusterScan, and an error, if there is any. +func (c *clusterScans) Create(ctx context.Context, clusterScan *v1alpha1.ClusterScan, opts v1.CreateOptions) (result *v1alpha1.ClusterScan, err error) { + result = &v1alpha1.ClusterScan{} + err = c.client.Post(). + Namespace(c.ns). + Resource("clusterscans"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(clusterScan). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a clusterScan and updates it. Returns the server's representation of the clusterScan, and an error, if there is any. +func (c *clusterScans) Update(ctx context.Context, clusterScan *v1alpha1.ClusterScan, opts v1.UpdateOptions) (result *v1alpha1.ClusterScan, err error) { + result = &v1alpha1.ClusterScan{} + err = c.client.Put(). + Namespace(c.ns). + Resource("clusterscans"). + Name(clusterScan.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(clusterScan). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *clusterScans) UpdateStatus(ctx context.Context, clusterScan *v1alpha1.ClusterScan, opts v1.UpdateOptions) (result *v1alpha1.ClusterScan, err error) { + result = &v1alpha1.ClusterScan{} + err = c.client.Put(). + Namespace(c.ns). + Resource("clusterscans"). + Name(clusterScan.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(clusterScan). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the clusterScan and deletes it. Returns an error if one occurs. +func (c *clusterScans) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("clusterscans"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *clusterScans) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("clusterscans"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched clusterScan. +func (c *clusterScans) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ClusterScan, err error) { + result = &v1alpha1.ClusterScan{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("clusterscans"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/clientset/versioned/typed/zora/v1alpha1/customcheck.go b/pkg/clientset/versioned/typed/zora/v1alpha1/customcheck.go new file mode 100644 index 00000000..207c4cdd --- /dev/null +++ b/pkg/clientset/versioned/typed/zora/v1alpha1/customcheck.go @@ -0,0 +1,179 @@ +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "time" + + v1alpha1 "github.com/undistro/zora/api/zora/v1alpha1" + scheme "github.com/undistro/zora/pkg/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// CustomChecksGetter has a method to return a CustomCheckInterface. +// A group's client should implement this interface. +type CustomChecksGetter interface { + CustomChecks(namespace string) CustomCheckInterface +} + +// CustomCheckInterface has methods to work with CustomCheck resources. +type CustomCheckInterface interface { + Create(ctx context.Context, customCheck *v1alpha1.CustomCheck, opts v1.CreateOptions) (*v1alpha1.CustomCheck, error) + Update(ctx context.Context, customCheck *v1alpha1.CustomCheck, opts v1.UpdateOptions) (*v1alpha1.CustomCheck, error) + UpdateStatus(ctx context.Context, customCheck *v1alpha1.CustomCheck, opts v1.UpdateOptions) (*v1alpha1.CustomCheck, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.CustomCheck, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.CustomCheckList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.CustomCheck, err error) + CustomCheckExpansion +} + +// customChecks implements CustomCheckInterface +type customChecks struct { + client rest.Interface + ns string +} + +// newCustomChecks returns a CustomChecks +func newCustomChecks(c *ZoraV1alpha1Client, namespace string) *customChecks { + return &customChecks{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the customCheck, and returns the corresponding customCheck object, and an error if there is any. +func (c *customChecks) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.CustomCheck, err error) { + result = &v1alpha1.CustomCheck{} + err = c.client.Get(). + Namespace(c.ns). + Resource("customchecks"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of CustomChecks that match those selectors. +func (c *customChecks) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.CustomCheckList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.CustomCheckList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("customchecks"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested customChecks. +func (c *customChecks) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("customchecks"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a customCheck and creates it. Returns the server's representation of the customCheck, and an error, if there is any. +func (c *customChecks) Create(ctx context.Context, customCheck *v1alpha1.CustomCheck, opts v1.CreateOptions) (result *v1alpha1.CustomCheck, err error) { + result = &v1alpha1.CustomCheck{} + err = c.client.Post(). + Namespace(c.ns). + Resource("customchecks"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(customCheck). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a customCheck and updates it. Returns the server's representation of the customCheck, and an error, if there is any. +func (c *customChecks) Update(ctx context.Context, customCheck *v1alpha1.CustomCheck, opts v1.UpdateOptions) (result *v1alpha1.CustomCheck, err error) { + result = &v1alpha1.CustomCheck{} + err = c.client.Put(). + Namespace(c.ns). + Resource("customchecks"). + Name(customCheck.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(customCheck). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *customChecks) UpdateStatus(ctx context.Context, customCheck *v1alpha1.CustomCheck, opts v1.UpdateOptions) (result *v1alpha1.CustomCheck, err error) { + result = &v1alpha1.CustomCheck{} + err = c.client.Put(). + Namespace(c.ns). + Resource("customchecks"). + Name(customCheck.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(customCheck). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the customCheck and deletes it. Returns an error if one occurs. +func (c *customChecks) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("customchecks"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *customChecks) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("customchecks"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched customCheck. +func (c *customChecks) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.CustomCheck, err error) { + result = &v1alpha1.CustomCheck{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("customchecks"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_cluster.go b/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_cluster.go index 184cbbb1..0e43f5a9 100644 --- a/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_cluster.go +++ b/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_cluster.go @@ -8,6 +8,8 @@ import ( v1alpha1 "github.com/undistro/zora/api/zora/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" ) @@ -53,3 +55,71 @@ func (c *FakeClusters) List(ctx context.Context, opts v1.ListOptions) (result *v } return list, err } + +// Watch returns a watch.Interface that watches the requested clusters. +func (c *FakeClusters) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(clustersResource, c.ns, opts)) + +} + +// Create takes the representation of a cluster and creates it. Returns the server's representation of the cluster, and an error, if there is any. +func (c *FakeClusters) Create(ctx context.Context, cluster *v1alpha1.Cluster, opts v1.CreateOptions) (result *v1alpha1.Cluster, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(clustersResource, c.ns, cluster), &v1alpha1.Cluster{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Cluster), err +} + +// Update takes the representation of a cluster and updates it. Returns the server's representation of the cluster, and an error, if there is any. +func (c *FakeClusters) Update(ctx context.Context, cluster *v1alpha1.Cluster, opts v1.UpdateOptions) (result *v1alpha1.Cluster, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(clustersResource, c.ns, cluster), &v1alpha1.Cluster{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Cluster), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeClusters) UpdateStatus(ctx context.Context, cluster *v1alpha1.Cluster, opts v1.UpdateOptions) (*v1alpha1.Cluster, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(clustersResource, "status", c.ns, cluster), &v1alpha1.Cluster{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Cluster), err +} + +// Delete takes name of the cluster and deletes it. Returns an error if one occurs. +func (c *FakeClusters) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(clustersResource, c.ns, name, opts), &v1alpha1.Cluster{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeClusters) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(clustersResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.ClusterList{}) + return err +} + +// Patch applies the patch and returns the patched cluster. +func (c *FakeClusters) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Cluster, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(clustersResource, c.ns, name, pt, data, subresources...), &v1alpha1.Cluster{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Cluster), err +} diff --git a/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_clusterissue.go b/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_clusterissue.go index 58bc6c6d..bcad3c71 100644 --- a/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_clusterissue.go +++ b/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_clusterissue.go @@ -85,6 +85,18 @@ func (c *FakeClusterIssues) Update(ctx context.Context, clusterIssue *v1alpha1.C return obj.(*v1alpha1.ClusterIssue), err } +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeClusterIssues) UpdateStatus(ctx context.Context, clusterIssue *v1alpha1.ClusterIssue, opts v1.UpdateOptions) (*v1alpha1.ClusterIssue, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(clusterissuesResource, "status", c.ns, clusterIssue), &v1alpha1.ClusterIssue{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterIssue), err +} + // Delete takes name of the clusterIssue and deletes it. Returns an error if one occurs. func (c *FakeClusterIssues) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. diff --git a/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_clusterscan.go b/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_clusterscan.go index 2c34ab54..a0342fa8 100644 --- a/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_clusterscan.go +++ b/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_clusterscan.go @@ -8,6 +8,8 @@ import ( v1alpha1 "github.com/undistro/zora/api/zora/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" ) @@ -53,3 +55,71 @@ func (c *FakeClusterScans) List(ctx context.Context, opts v1.ListOptions) (resul } return list, err } + +// Watch returns a watch.Interface that watches the requested clusterScans. +func (c *FakeClusterScans) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(clusterscansResource, c.ns, opts)) + +} + +// Create takes the representation of a clusterScan and creates it. Returns the server's representation of the clusterScan, and an error, if there is any. +func (c *FakeClusterScans) Create(ctx context.Context, clusterScan *v1alpha1.ClusterScan, opts v1.CreateOptions) (result *v1alpha1.ClusterScan, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(clusterscansResource, c.ns, clusterScan), &v1alpha1.ClusterScan{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterScan), err +} + +// Update takes the representation of a clusterScan and updates it. Returns the server's representation of the clusterScan, and an error, if there is any. +func (c *FakeClusterScans) Update(ctx context.Context, clusterScan *v1alpha1.ClusterScan, opts v1.UpdateOptions) (result *v1alpha1.ClusterScan, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(clusterscansResource, c.ns, clusterScan), &v1alpha1.ClusterScan{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterScan), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeClusterScans) UpdateStatus(ctx context.Context, clusterScan *v1alpha1.ClusterScan, opts v1.UpdateOptions) (*v1alpha1.ClusterScan, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(clusterscansResource, "status", c.ns, clusterScan), &v1alpha1.ClusterScan{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterScan), err +} + +// Delete takes name of the clusterScan and deletes it. Returns an error if one occurs. +func (c *FakeClusterScans) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(clusterscansResource, c.ns, name, opts), &v1alpha1.ClusterScan{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeClusterScans) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(clusterscansResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.ClusterScanList{}) + return err +} + +// Patch applies the patch and returns the patched clusterScan. +func (c *FakeClusterScans) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ClusterScan, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(clusterscansResource, c.ns, name, pt, data, subresources...), &v1alpha1.ClusterScan{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterScan), err +} diff --git a/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_customcheck.go b/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_customcheck.go new file mode 100644 index 00000000..8c3c8e2f --- /dev/null +++ b/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_customcheck.go @@ -0,0 +1,125 @@ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1alpha1 "github.com/undistro/zora/api/zora/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeCustomChecks implements CustomCheckInterface +type FakeCustomChecks struct { + Fake *FakeZoraV1alpha1 + ns string +} + +var customchecksResource = v1alpha1.SchemeGroupVersion.WithResource("customchecks") + +var customchecksKind = v1alpha1.SchemeGroupVersion.WithKind("CustomCheck") + +// Get takes name of the customCheck, and returns the corresponding customCheck object, and an error if there is any. +func (c *FakeCustomChecks) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.CustomCheck, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(customchecksResource, c.ns, name), &v1alpha1.CustomCheck{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.CustomCheck), err +} + +// List takes label and field selectors, and returns the list of CustomChecks that match those selectors. +func (c *FakeCustomChecks) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.CustomCheckList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(customchecksResource, customchecksKind, c.ns, opts), &v1alpha1.CustomCheckList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.CustomCheckList{ListMeta: obj.(*v1alpha1.CustomCheckList).ListMeta} + for _, item := range obj.(*v1alpha1.CustomCheckList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested customChecks. +func (c *FakeCustomChecks) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(customchecksResource, c.ns, opts)) + +} + +// Create takes the representation of a customCheck and creates it. Returns the server's representation of the customCheck, and an error, if there is any. +func (c *FakeCustomChecks) Create(ctx context.Context, customCheck *v1alpha1.CustomCheck, opts v1.CreateOptions) (result *v1alpha1.CustomCheck, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(customchecksResource, c.ns, customCheck), &v1alpha1.CustomCheck{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.CustomCheck), err +} + +// Update takes the representation of a customCheck and updates it. Returns the server's representation of the customCheck, and an error, if there is any. +func (c *FakeCustomChecks) Update(ctx context.Context, customCheck *v1alpha1.CustomCheck, opts v1.UpdateOptions) (result *v1alpha1.CustomCheck, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(customchecksResource, c.ns, customCheck), &v1alpha1.CustomCheck{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.CustomCheck), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeCustomChecks) UpdateStatus(ctx context.Context, customCheck *v1alpha1.CustomCheck, opts v1.UpdateOptions) (*v1alpha1.CustomCheck, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(customchecksResource, "status", c.ns, customCheck), &v1alpha1.CustomCheck{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.CustomCheck), err +} + +// Delete takes name of the customCheck and deletes it. Returns an error if one occurs. +func (c *FakeCustomChecks) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(customchecksResource, c.ns, name, opts), &v1alpha1.CustomCheck{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeCustomChecks) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(customchecksResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.CustomCheckList{}) + return err +} + +// Patch applies the patch and returns the patched customCheck. +func (c *FakeCustomChecks) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.CustomCheck, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(customchecksResource, c.ns, name, pt, data, subresources...), &v1alpha1.CustomCheck{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.CustomCheck), err +} diff --git a/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_plugin.go b/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_plugin.go new file mode 100644 index 00000000..12d1b160 --- /dev/null +++ b/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_plugin.go @@ -0,0 +1,125 @@ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1alpha1 "github.com/undistro/zora/api/zora/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakePlugins implements PluginInterface +type FakePlugins struct { + Fake *FakeZoraV1alpha1 + ns string +} + +var pluginsResource = v1alpha1.SchemeGroupVersion.WithResource("plugins") + +var pluginsKind = v1alpha1.SchemeGroupVersion.WithKind("Plugin") + +// Get takes name of the plugin, and returns the corresponding plugin object, and an error if there is any. +func (c *FakePlugins) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Plugin, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(pluginsResource, c.ns, name), &v1alpha1.Plugin{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Plugin), err +} + +// List takes label and field selectors, and returns the list of Plugins that match those selectors. +func (c *FakePlugins) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.PluginList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(pluginsResource, pluginsKind, c.ns, opts), &v1alpha1.PluginList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.PluginList{ListMeta: obj.(*v1alpha1.PluginList).ListMeta} + for _, item := range obj.(*v1alpha1.PluginList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested plugins. +func (c *FakePlugins) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(pluginsResource, c.ns, opts)) + +} + +// Create takes the representation of a plugin and creates it. Returns the server's representation of the plugin, and an error, if there is any. +func (c *FakePlugins) Create(ctx context.Context, plugin *v1alpha1.Plugin, opts v1.CreateOptions) (result *v1alpha1.Plugin, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(pluginsResource, c.ns, plugin), &v1alpha1.Plugin{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Plugin), err +} + +// Update takes the representation of a plugin and updates it. Returns the server's representation of the plugin, and an error, if there is any. +func (c *FakePlugins) Update(ctx context.Context, plugin *v1alpha1.Plugin, opts v1.UpdateOptions) (result *v1alpha1.Plugin, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(pluginsResource, c.ns, plugin), &v1alpha1.Plugin{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Plugin), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakePlugins) UpdateStatus(ctx context.Context, plugin *v1alpha1.Plugin, opts v1.UpdateOptions) (*v1alpha1.Plugin, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(pluginsResource, "status", c.ns, plugin), &v1alpha1.Plugin{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Plugin), err +} + +// Delete takes name of the plugin and deletes it. Returns an error if one occurs. +func (c *FakePlugins) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(pluginsResource, c.ns, name, opts), &v1alpha1.Plugin{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakePlugins) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(pluginsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.PluginList{}) + return err +} + +// Patch applies the patch and returns the patched plugin. +func (c *FakePlugins) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Plugin, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(pluginsResource, c.ns, name, pt, data, subresources...), &v1alpha1.Plugin{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Plugin), err +} diff --git a/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_vulnerabilityreport.go b/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_vulnerabilityreport.go index 27f77329..17603419 100644 --- a/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_vulnerabilityreport.go +++ b/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_vulnerabilityreport.go @@ -85,6 +85,18 @@ func (c *FakeVulnerabilityReports) Update(ctx context.Context, vulnerabilityRepo return obj.(*v1alpha1.VulnerabilityReport), err } +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeVulnerabilityReports) UpdateStatus(ctx context.Context, vulnerabilityReport *v1alpha1.VulnerabilityReport, opts v1.UpdateOptions) (*v1alpha1.VulnerabilityReport, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(vulnerabilityreportsResource, "status", c.ns, vulnerabilityReport), &v1alpha1.VulnerabilityReport{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.VulnerabilityReport), err +} + // Delete takes name of the vulnerabilityReport and deletes it. Returns an error if one occurs. func (c *FakeVulnerabilityReports) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. diff --git a/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_zora_client.go b/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_zora_client.go index 39b79999..943b4d66 100644 --- a/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_zora_client.go +++ b/pkg/clientset/versioned/typed/zora/v1alpha1/fake/fake_zora_client.go @@ -24,6 +24,14 @@ func (c *FakeZoraV1alpha1) ClusterScans(namespace string) v1alpha1.ClusterScanIn return &FakeClusterScans{c, namespace} } +func (c *FakeZoraV1alpha1) CustomChecks(namespace string) v1alpha1.CustomCheckInterface { + return &FakeCustomChecks{c, namespace} +} + +func (c *FakeZoraV1alpha1) Plugins(namespace string) v1alpha1.PluginInterface { + return &FakePlugins{c, namespace} +} + func (c *FakeZoraV1alpha1) VulnerabilityReports(namespace string) v1alpha1.VulnerabilityReportInterface { return &FakeVulnerabilityReports{c, namespace} } diff --git a/pkg/clientset/versioned/typed/zora/v1alpha1/generated_expansion.go b/pkg/clientset/versioned/typed/zora/v1alpha1/generated_expansion.go index 07ffdf10..9dba528d 100644 --- a/pkg/clientset/versioned/typed/zora/v1alpha1/generated_expansion.go +++ b/pkg/clientset/versioned/typed/zora/v1alpha1/generated_expansion.go @@ -8,4 +8,8 @@ type ClusterIssueExpansion interface{} type ClusterScanExpansion interface{} +type CustomCheckExpansion interface{} + +type PluginExpansion interface{} + type VulnerabilityReportExpansion interface{} diff --git a/pkg/clientset/versioned/typed/zora/v1alpha1/plugin.go b/pkg/clientset/versioned/typed/zora/v1alpha1/plugin.go new file mode 100644 index 00000000..1a0254fa --- /dev/null +++ b/pkg/clientset/versioned/typed/zora/v1alpha1/plugin.go @@ -0,0 +1,179 @@ +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "time" + + v1alpha1 "github.com/undistro/zora/api/zora/v1alpha1" + scheme "github.com/undistro/zora/pkg/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// PluginsGetter has a method to return a PluginInterface. +// A group's client should implement this interface. +type PluginsGetter interface { + Plugins(namespace string) PluginInterface +} + +// PluginInterface has methods to work with Plugin resources. +type PluginInterface interface { + Create(ctx context.Context, plugin *v1alpha1.Plugin, opts v1.CreateOptions) (*v1alpha1.Plugin, error) + Update(ctx context.Context, plugin *v1alpha1.Plugin, opts v1.UpdateOptions) (*v1alpha1.Plugin, error) + UpdateStatus(ctx context.Context, plugin *v1alpha1.Plugin, opts v1.UpdateOptions) (*v1alpha1.Plugin, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.Plugin, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.PluginList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Plugin, err error) + PluginExpansion +} + +// plugins implements PluginInterface +type plugins struct { + client rest.Interface + ns string +} + +// newPlugins returns a Plugins +func newPlugins(c *ZoraV1alpha1Client, namespace string) *plugins { + return &plugins{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the plugin, and returns the corresponding plugin object, and an error if there is any. +func (c *plugins) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Plugin, err error) { + result = &v1alpha1.Plugin{} + err = c.client.Get(). + Namespace(c.ns). + Resource("plugins"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Plugins that match those selectors. +func (c *plugins) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.PluginList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.PluginList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("plugins"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested plugins. +func (c *plugins) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("plugins"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a plugin and creates it. Returns the server's representation of the plugin, and an error, if there is any. +func (c *plugins) Create(ctx context.Context, plugin *v1alpha1.Plugin, opts v1.CreateOptions) (result *v1alpha1.Plugin, err error) { + result = &v1alpha1.Plugin{} + err = c.client.Post(). + Namespace(c.ns). + Resource("plugins"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(plugin). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a plugin and updates it. Returns the server's representation of the plugin, and an error, if there is any. +func (c *plugins) Update(ctx context.Context, plugin *v1alpha1.Plugin, opts v1.UpdateOptions) (result *v1alpha1.Plugin, err error) { + result = &v1alpha1.Plugin{} + err = c.client.Put(). + Namespace(c.ns). + Resource("plugins"). + Name(plugin.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(plugin). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *plugins) UpdateStatus(ctx context.Context, plugin *v1alpha1.Plugin, opts v1.UpdateOptions) (result *v1alpha1.Plugin, err error) { + result = &v1alpha1.Plugin{} + err = c.client.Put(). + Namespace(c.ns). + Resource("plugins"). + Name(plugin.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(plugin). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the plugin and deletes it. Returns an error if one occurs. +func (c *plugins) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("plugins"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *plugins) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("plugins"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched plugin. +func (c *plugins) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Plugin, err error) { + result = &v1alpha1.Plugin{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("plugins"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/clientset/versioned/typed/zora/v1alpha1/vulnerabilityreport.go b/pkg/clientset/versioned/typed/zora/v1alpha1/vulnerabilityreport.go index 7d8cb588..2eb3caf2 100644 --- a/pkg/clientset/versioned/typed/zora/v1alpha1/vulnerabilityreport.go +++ b/pkg/clientset/versioned/typed/zora/v1alpha1/vulnerabilityreport.go @@ -24,6 +24,7 @@ type VulnerabilityReportsGetter interface { type VulnerabilityReportInterface interface { Create(ctx context.Context, vulnerabilityReport *v1alpha1.VulnerabilityReport, opts v1.CreateOptions) (*v1alpha1.VulnerabilityReport, error) Update(ctx context.Context, vulnerabilityReport *v1alpha1.VulnerabilityReport, opts v1.UpdateOptions) (*v1alpha1.VulnerabilityReport, error) + UpdateStatus(ctx context.Context, vulnerabilityReport *v1alpha1.VulnerabilityReport, opts v1.UpdateOptions) (*v1alpha1.VulnerabilityReport, error) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.VulnerabilityReport, error) @@ -119,6 +120,22 @@ func (c *vulnerabilityReports) Update(ctx context.Context, vulnerabilityReport * return } +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *vulnerabilityReports) UpdateStatus(ctx context.Context, vulnerabilityReport *v1alpha1.VulnerabilityReport, opts v1.UpdateOptions) (result *v1alpha1.VulnerabilityReport, err error) { + result = &v1alpha1.VulnerabilityReport{} + err = c.client.Put(). + Namespace(c.ns). + Resource("vulnerabilityreports"). + Name(vulnerabilityReport.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(vulnerabilityReport). + Do(ctx). + Into(result) + return +} + // Delete takes name of the vulnerabilityReport and deletes it. Returns an error if one occurs. func (c *vulnerabilityReports) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { return c.client.Delete(). diff --git a/pkg/clientset/versioned/typed/zora/v1alpha1/zora_client.go b/pkg/clientset/versioned/typed/zora/v1alpha1/zora_client.go index a966f3c0..9dd56865 100644 --- a/pkg/clientset/versioned/typed/zora/v1alpha1/zora_client.go +++ b/pkg/clientset/versioned/typed/zora/v1alpha1/zora_client.go @@ -15,6 +15,8 @@ type ZoraV1alpha1Interface interface { ClustersGetter ClusterIssuesGetter ClusterScansGetter + CustomChecksGetter + PluginsGetter VulnerabilityReportsGetter } @@ -35,6 +37,14 @@ func (c *ZoraV1alpha1Client) ClusterScans(namespace string) ClusterScanInterface return newClusterScans(c, namespace) } +func (c *ZoraV1alpha1Client) CustomChecks(namespace string) CustomCheckInterface { + return newCustomChecks(c, namespace) +} + +func (c *ZoraV1alpha1Client) Plugins(namespace string) PluginInterface { + return newPlugins(c, namespace) +} + func (c *ZoraV1alpha1Client) VulnerabilityReports(namespace string) VulnerabilityReportInterface { return newVulnerabilityReports(c, namespace) } diff --git a/pkg/clientset/versioned/typed/zora/v1alpha2/customcheck.go b/pkg/clientset/versioned/typed/zora/v1alpha2/customcheck.go new file mode 100644 index 00000000..9060ed12 --- /dev/null +++ b/pkg/clientset/versioned/typed/zora/v1alpha2/customcheck.go @@ -0,0 +1,179 @@ +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + "context" + "time" + + v1alpha2 "github.com/undistro/zora/api/zora/v1alpha2" + scheme "github.com/undistro/zora/pkg/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// CustomChecksGetter has a method to return a CustomCheckInterface. +// A group's client should implement this interface. +type CustomChecksGetter interface { + CustomChecks(namespace string) CustomCheckInterface +} + +// CustomCheckInterface has methods to work with CustomCheck resources. +type CustomCheckInterface interface { + Create(ctx context.Context, customCheck *v1alpha2.CustomCheck, opts v1.CreateOptions) (*v1alpha2.CustomCheck, error) + Update(ctx context.Context, customCheck *v1alpha2.CustomCheck, opts v1.UpdateOptions) (*v1alpha2.CustomCheck, error) + UpdateStatus(ctx context.Context, customCheck *v1alpha2.CustomCheck, opts v1.UpdateOptions) (*v1alpha2.CustomCheck, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha2.CustomCheck, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.CustomCheckList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.CustomCheck, err error) + CustomCheckExpansion +} + +// customChecks implements CustomCheckInterface +type customChecks struct { + client rest.Interface + ns string +} + +// newCustomChecks returns a CustomChecks +func newCustomChecks(c *ZoraV1alpha2Client, namespace string) *customChecks { + return &customChecks{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the customCheck, and returns the corresponding customCheck object, and an error if there is any. +func (c *customChecks) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.CustomCheck, err error) { + result = &v1alpha2.CustomCheck{} + err = c.client.Get(). + Namespace(c.ns). + Resource("customchecks"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of CustomChecks that match those selectors. +func (c *customChecks) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.CustomCheckList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha2.CustomCheckList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("customchecks"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested customChecks. +func (c *customChecks) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("customchecks"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a customCheck and creates it. Returns the server's representation of the customCheck, and an error, if there is any. +func (c *customChecks) Create(ctx context.Context, customCheck *v1alpha2.CustomCheck, opts v1.CreateOptions) (result *v1alpha2.CustomCheck, err error) { + result = &v1alpha2.CustomCheck{} + err = c.client.Post(). + Namespace(c.ns). + Resource("customchecks"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(customCheck). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a customCheck and updates it. Returns the server's representation of the customCheck, and an error, if there is any. +func (c *customChecks) Update(ctx context.Context, customCheck *v1alpha2.CustomCheck, opts v1.UpdateOptions) (result *v1alpha2.CustomCheck, err error) { + result = &v1alpha2.CustomCheck{} + err = c.client.Put(). + Namespace(c.ns). + Resource("customchecks"). + Name(customCheck.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(customCheck). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *customChecks) UpdateStatus(ctx context.Context, customCheck *v1alpha2.CustomCheck, opts v1.UpdateOptions) (result *v1alpha2.CustomCheck, err error) { + result = &v1alpha2.CustomCheck{} + err = c.client.Put(). + Namespace(c.ns). + Resource("customchecks"). + Name(customCheck.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(customCheck). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the customCheck and deletes it. Returns an error if one occurs. +func (c *customChecks) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("customchecks"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *customChecks) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("customchecks"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched customCheck. +func (c *customChecks) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.CustomCheck, err error) { + result = &v1alpha2.CustomCheck{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("customchecks"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/clientset/versioned/typed/zora/v1alpha2/doc.go b/pkg/clientset/versioned/typed/zora/v1alpha2/doc.go new file mode 100644 index 00000000..c11da268 --- /dev/null +++ b/pkg/clientset/versioned/typed/zora/v1alpha2/doc.go @@ -0,0 +1,4 @@ +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha2 diff --git a/pkg/clientset/versioned/typed/zora/v1alpha2/fake/doc.go b/pkg/clientset/versioned/typed/zora/v1alpha2/fake/doc.go new file mode 100644 index 00000000..2b5ba4c8 --- /dev/null +++ b/pkg/clientset/versioned/typed/zora/v1alpha2/fake/doc.go @@ -0,0 +1,4 @@ +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/pkg/clientset/versioned/typed/zora/v1alpha2/fake/fake_customcheck.go b/pkg/clientset/versioned/typed/zora/v1alpha2/fake/fake_customcheck.go new file mode 100644 index 00000000..0f18e795 --- /dev/null +++ b/pkg/clientset/versioned/typed/zora/v1alpha2/fake/fake_customcheck.go @@ -0,0 +1,125 @@ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1alpha2 "github.com/undistro/zora/api/zora/v1alpha2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeCustomChecks implements CustomCheckInterface +type FakeCustomChecks struct { + Fake *FakeZoraV1alpha2 + ns string +} + +var customchecksResource = v1alpha2.SchemeGroupVersion.WithResource("customchecks") + +var customchecksKind = v1alpha2.SchemeGroupVersion.WithKind("CustomCheck") + +// Get takes name of the customCheck, and returns the corresponding customCheck object, and an error if there is any. +func (c *FakeCustomChecks) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.CustomCheck, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(customchecksResource, c.ns, name), &v1alpha2.CustomCheck{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.CustomCheck), err +} + +// List takes label and field selectors, and returns the list of CustomChecks that match those selectors. +func (c *FakeCustomChecks) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.CustomCheckList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(customchecksResource, customchecksKind, c.ns, opts), &v1alpha2.CustomCheckList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha2.CustomCheckList{ListMeta: obj.(*v1alpha2.CustomCheckList).ListMeta} + for _, item := range obj.(*v1alpha2.CustomCheckList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested customChecks. +func (c *FakeCustomChecks) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(customchecksResource, c.ns, opts)) + +} + +// Create takes the representation of a customCheck and creates it. Returns the server's representation of the customCheck, and an error, if there is any. +func (c *FakeCustomChecks) Create(ctx context.Context, customCheck *v1alpha2.CustomCheck, opts v1.CreateOptions) (result *v1alpha2.CustomCheck, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(customchecksResource, c.ns, customCheck), &v1alpha2.CustomCheck{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.CustomCheck), err +} + +// Update takes the representation of a customCheck and updates it. Returns the server's representation of the customCheck, and an error, if there is any. +func (c *FakeCustomChecks) Update(ctx context.Context, customCheck *v1alpha2.CustomCheck, opts v1.UpdateOptions) (result *v1alpha2.CustomCheck, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(customchecksResource, c.ns, customCheck), &v1alpha2.CustomCheck{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.CustomCheck), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeCustomChecks) UpdateStatus(ctx context.Context, customCheck *v1alpha2.CustomCheck, opts v1.UpdateOptions) (*v1alpha2.CustomCheck, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(customchecksResource, "status", c.ns, customCheck), &v1alpha2.CustomCheck{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.CustomCheck), err +} + +// Delete takes name of the customCheck and deletes it. Returns an error if one occurs. +func (c *FakeCustomChecks) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(customchecksResource, c.ns, name, opts), &v1alpha2.CustomCheck{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeCustomChecks) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(customchecksResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha2.CustomCheckList{}) + return err +} + +// Patch applies the patch and returns the patched customCheck. +func (c *FakeCustomChecks) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.CustomCheck, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(customchecksResource, c.ns, name, pt, data, subresources...), &v1alpha2.CustomCheck{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.CustomCheck), err +} diff --git a/pkg/clientset/versioned/typed/zora/v1alpha2/fake/fake_zora_client.go b/pkg/clientset/versioned/typed/zora/v1alpha2/fake/fake_zora_client.go new file mode 100644 index 00000000..f8fbb14f --- /dev/null +++ b/pkg/clientset/versioned/typed/zora/v1alpha2/fake/fake_zora_client.go @@ -0,0 +1,24 @@ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha2 "github.com/undistro/zora/pkg/clientset/versioned/typed/zora/v1alpha2" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeZoraV1alpha2 struct { + *testing.Fake +} + +func (c *FakeZoraV1alpha2) CustomChecks(namespace string) v1alpha2.CustomCheckInterface { + return &FakeCustomChecks{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeZoraV1alpha2) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/clientset/versioned/typed/zora/v1alpha2/generated_expansion.go b/pkg/clientset/versioned/typed/zora/v1alpha2/generated_expansion.go new file mode 100644 index 00000000..b2745581 --- /dev/null +++ b/pkg/clientset/versioned/typed/zora/v1alpha2/generated_expansion.go @@ -0,0 +1,5 @@ +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha2 + +type CustomCheckExpansion interface{} diff --git a/pkg/clientset/versioned/typed/zora/v1alpha2/zora_client.go b/pkg/clientset/versioned/typed/zora/v1alpha2/zora_client.go new file mode 100644 index 00000000..c8404871 --- /dev/null +++ b/pkg/clientset/versioned/typed/zora/v1alpha2/zora_client.go @@ -0,0 +1,91 @@ +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + "net/http" + + v1alpha2 "github.com/undistro/zora/api/zora/v1alpha2" + "github.com/undistro/zora/pkg/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type ZoraV1alpha2Interface interface { + RESTClient() rest.Interface + CustomChecksGetter +} + +// ZoraV1alpha2Client is used to interact with features provided by the zora group. +type ZoraV1alpha2Client struct { + restClient rest.Interface +} + +func (c *ZoraV1alpha2Client) CustomChecks(namespace string) CustomCheckInterface { + return newCustomChecks(c, namespace) +} + +// NewForConfig creates a new ZoraV1alpha2Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*ZoraV1alpha2Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new ZoraV1alpha2Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*ZoraV1alpha2Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &ZoraV1alpha2Client{client}, nil +} + +// NewForConfigOrDie creates a new ZoraV1alpha2Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *ZoraV1alpha2Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new ZoraV1alpha2Client for the given RESTClient. +func New(c rest.Interface) *ZoraV1alpha2Client { + return &ZoraV1alpha2Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha2.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *ZoraV1alpha2Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/informers/externalversions/factory.go b/pkg/informers/externalversions/factory.go new file mode 100644 index 00000000..50cc50e6 --- /dev/null +++ b/pkg/informers/externalversions/factory.go @@ -0,0 +1,245 @@ +// Code generated by informer-gen. DO NOT EDIT. + +package externalversions + +import ( + reflect "reflect" + sync "sync" + time "time" + + versioned "github.com/undistro/zora/pkg/clientset/versioned" + internalinterfaces "github.com/undistro/zora/pkg/informers/externalversions/internalinterfaces" + zora "github.com/undistro/zora/pkg/informers/externalversions/zora" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// SharedInformerOption defines the functional option type for SharedInformerFactory. +type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory + +type sharedInformerFactory struct { + client versioned.Interface + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc + lock sync.Mutex + defaultResync time.Duration + customResync map[reflect.Type]time.Duration + transform cache.TransformFunc + + informers map[reflect.Type]cache.SharedIndexInformer + // startedInformers is used for tracking which informers have been started. + // This allows Start() to be called multiple times safely. + startedInformers map[reflect.Type]bool + // wg tracks how many goroutines were started. + wg sync.WaitGroup + // shuttingDown is true when Shutdown has been called. It may still be running + // because it needs to wait for goroutines. + shuttingDown bool +} + +// WithCustomResyncConfig sets a custom resync period for the specified informer types. +func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + for k, v := range resyncConfig { + factory.customResync[reflect.TypeOf(k)] = v + } + return factory + } +} + +// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory. +func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.tweakListOptions = tweakListOptions + return factory + } +} + +// WithNamespace limits the SharedInformerFactory to the specified namespace. +func WithNamespace(namespace string) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.namespace = namespace + return factory + } +} + +// WithTransform sets a transform on all informers. +func WithTransform(transform cache.TransformFunc) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.transform = transform + return factory + } +} + +// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces. +func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync) +} + +// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. +// Listers obtained via this SharedInformerFactory will be subject to the same filters +// as specified here. +// Deprecated: Please use NewSharedInformerFactoryWithOptions instead +func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions)) +} + +// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options. +func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { + factory := &sharedInformerFactory{ + client: client, + namespace: v1.NamespaceAll, + defaultResync: defaultResync, + informers: make(map[reflect.Type]cache.SharedIndexInformer), + startedInformers: make(map[reflect.Type]bool), + customResync: make(map[reflect.Type]time.Duration), + } + + // Apply all options + for _, opt := range options { + factory = opt(factory) + } + + return factory +} + +func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { + f.lock.Lock() + defer f.lock.Unlock() + + if f.shuttingDown { + return + } + + for informerType, informer := range f.informers { + if !f.startedInformers[informerType] { + f.wg.Add(1) + // We need a new variable in each loop iteration, + // otherwise the goroutine would use the loop variable + // and that keeps changing. + informer := informer + go func() { + defer f.wg.Done() + informer.Run(stopCh) + }() + f.startedInformers[informerType] = true + } + } +} + +func (f *sharedInformerFactory) Shutdown() { + f.lock.Lock() + f.shuttingDown = true + f.lock.Unlock() + + // Will return immediately if there is nothing to wait for. + f.wg.Wait() +} + +func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { + informers := func() map[reflect.Type]cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informers := map[reflect.Type]cache.SharedIndexInformer{} + for informerType, informer := range f.informers { + if f.startedInformers[informerType] { + informers[informerType] = informer + } + } + return informers + }() + + res := map[reflect.Type]bool{} + for informType, informer := range informers { + res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) + } + return res +} + +// InformerFor returns the SharedIndexInformer for obj using an internal +// client. +func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informerType := reflect.TypeOf(obj) + informer, exists := f.informers[informerType] + if exists { + return informer + } + + resyncPeriod, exists := f.customResync[informerType] + if !exists { + resyncPeriod = f.defaultResync + } + + informer = newFunc(f.client, resyncPeriod) + informer.SetTransform(f.transform) + f.informers[informerType] = informer + + return informer +} + +// SharedInformerFactory provides shared informers for resources in all known +// API group versions. +// +// It is typically used like this: +// +// ctx, cancel := context.Background() +// defer cancel() +// factory := NewSharedInformerFactory(client, resyncPeriod) +// defer factory.WaitForStop() // Returns immediately if nothing was started. +// genericInformer := factory.ForResource(resource) +// typedInformer := factory.SomeAPIGroup().V1().SomeType() +// factory.Start(ctx.Done()) // Start processing these informers. +// synced := factory.WaitForCacheSync(ctx.Done()) +// for v, ok := range synced { +// if !ok { +// fmt.Fprintf(os.Stderr, "caches failed to sync: %v", v) +// return +// } +// } +// +// // Creating informers can also be created after Start, but then +// // Start must be called again: +// anotherGenericInformer := factory.ForResource(resource) +// factory.Start(ctx.Done()) +type SharedInformerFactory interface { + internalinterfaces.SharedInformerFactory + + // Start initializes all requested informers. They are handled in goroutines + // which run until the stop channel gets closed. + Start(stopCh <-chan struct{}) + + // Shutdown marks a factory as shutting down. At that point no new + // informers can be started anymore and Start will return without + // doing anything. + // + // In addition, Shutdown blocks until all goroutines have terminated. For that + // to happen, the close channel(s) that they were started with must be closed, + // either before Shutdown gets called or while it is waiting. + // + // Shutdown may be called multiple times, even concurrently. All such calls will + // block until all goroutines have terminated. + Shutdown() + + // WaitForCacheSync blocks until all started informers' caches were synced + // or the stop channel gets closed. + WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool + + // ForResource gives generic access to a shared informer of the matching type. + ForResource(resource schema.GroupVersionResource) (GenericInformer, error) + + // InformerFor returns the SharedIndexInformer for obj using an internal + // client. + InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer + + Zora() zora.Interface +} + +func (f *sharedInformerFactory) Zora() zora.Interface { + return zora.New(f, f.namespace, f.tweakListOptions) +} diff --git a/pkg/informers/externalversions/generic.go b/pkg/informers/externalversions/generic.go new file mode 100644 index 00000000..2da68de1 --- /dev/null +++ b/pkg/informers/externalversions/generic.go @@ -0,0 +1,61 @@ +// Code generated by informer-gen. DO NOT EDIT. + +package externalversions + +import ( + "fmt" + + v1alpha1 "github.com/undistro/zora/api/zora/v1alpha1" + v1alpha2 "github.com/undistro/zora/api/zora/v1alpha2" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// GenericInformer is type of SharedIndexInformer which will locate and delegate to other +// sharedInformers based on type +type GenericInformer interface { + Informer() cache.SharedIndexInformer + Lister() cache.GenericLister +} + +type genericInformer struct { + informer cache.SharedIndexInformer + resource schema.GroupResource +} + +// Informer returns the SharedIndexInformer. +func (f *genericInformer) Informer() cache.SharedIndexInformer { + return f.informer +} + +// Lister returns the GenericLister. +func (f *genericInformer) Lister() cache.GenericLister { + return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) +} + +// ForResource gives generic access to a shared informer of the matching type +// TODO extend this to unknown resources with a client pool +func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { + switch resource { + // Group=zora, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("clusters"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Zora().V1alpha1().Clusters().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("clusterissues"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Zora().V1alpha1().ClusterIssues().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("clusterscans"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Zora().V1alpha1().ClusterScans().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("customchecks"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Zora().V1alpha1().CustomChecks().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("plugins"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Zora().V1alpha1().Plugins().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("vulnerabilityreports"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Zora().V1alpha1().VulnerabilityReports().Informer()}, nil + + // Group=zora, Version=v1alpha2 + case v1alpha2.SchemeGroupVersion.WithResource("customchecks"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Zora().V1alpha2().CustomChecks().Informer()}, nil + + } + + return nil, fmt.Errorf("no informer found for %v", resource) +} diff --git a/pkg/informers/externalversions/internalinterfaces/factory_interfaces.go b/pkg/informers/externalversions/internalinterfaces/factory_interfaces.go new file mode 100644 index 00000000..b623611a --- /dev/null +++ b/pkg/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -0,0 +1,24 @@ +// Code generated by informer-gen. DO NOT EDIT. + +package internalinterfaces + +import ( + time "time" + + versioned "github.com/undistro/zora/pkg/clientset/versioned" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + cache "k8s.io/client-go/tools/cache" +) + +// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer. +type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer + +// SharedInformerFactory a small interface to allow for adding an informer without an import cycle +type SharedInformerFactory interface { + Start(stopCh <-chan struct{}) + InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer +} + +// TweakListOptionsFunc is a function that transforms a v1.ListOptions. +type TweakListOptionsFunc func(*v1.ListOptions) diff --git a/pkg/informers/externalversions/zora/interface.go b/pkg/informers/externalversions/zora/interface.go new file mode 100644 index 00000000..72a8663c --- /dev/null +++ b/pkg/informers/externalversions/zora/interface.go @@ -0,0 +1,38 @@ +// Code generated by informer-gen. DO NOT EDIT. + +package zora + +import ( + internalinterfaces "github.com/undistro/zora/pkg/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/undistro/zora/pkg/informers/externalversions/zora/v1alpha1" + v1alpha2 "github.com/undistro/zora/pkg/informers/externalversions/zora/v1alpha2" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface + // V1alpha2 provides access to shared informers for resources in V1alpha2. + V1alpha2() v1alpha2.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} + +// V1alpha2 returns a new v1alpha2.Interface. +func (g *group) V1alpha2() v1alpha2.Interface { + return v1alpha2.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/informers/externalversions/zora/v1alpha1/cluster.go b/pkg/informers/externalversions/zora/v1alpha1/cluster.go new file mode 100644 index 00000000..d148291c --- /dev/null +++ b/pkg/informers/externalversions/zora/v1alpha1/cluster.go @@ -0,0 +1,74 @@ +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + zorav1alpha1 "github.com/undistro/zora/api/zora/v1alpha1" + versioned "github.com/undistro/zora/pkg/clientset/versioned" + internalinterfaces "github.com/undistro/zora/pkg/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/undistro/zora/pkg/listers/zora/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// ClusterInformer provides access to a shared informer and lister for +// Clusters. +type ClusterInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.ClusterLister +} + +type clusterInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewClusterInformer constructs a new informer for Cluster type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewClusterInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredClusterInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredClusterInformer constructs a new informer for Cluster type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredClusterInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ZoraV1alpha1().Clusters(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ZoraV1alpha1().Clusters(namespace).Watch(context.TODO(), options) + }, + }, + &zorav1alpha1.Cluster{}, + resyncPeriod, + indexers, + ) +} + +func (f *clusterInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredClusterInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *clusterInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&zorav1alpha1.Cluster{}, f.defaultInformer) +} + +func (f *clusterInformer) Lister() v1alpha1.ClusterLister { + return v1alpha1.NewClusterLister(f.Informer().GetIndexer()) +} diff --git a/pkg/informers/externalversions/zora/v1alpha1/clusterissue.go b/pkg/informers/externalversions/zora/v1alpha1/clusterissue.go new file mode 100644 index 00000000..812c46c6 --- /dev/null +++ b/pkg/informers/externalversions/zora/v1alpha1/clusterissue.go @@ -0,0 +1,74 @@ +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + zorav1alpha1 "github.com/undistro/zora/api/zora/v1alpha1" + versioned "github.com/undistro/zora/pkg/clientset/versioned" + internalinterfaces "github.com/undistro/zora/pkg/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/undistro/zora/pkg/listers/zora/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// ClusterIssueInformer provides access to a shared informer and lister for +// ClusterIssues. +type ClusterIssueInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.ClusterIssueLister +} + +type clusterIssueInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewClusterIssueInformer constructs a new informer for ClusterIssue type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewClusterIssueInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredClusterIssueInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredClusterIssueInformer constructs a new informer for ClusterIssue type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredClusterIssueInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ZoraV1alpha1().ClusterIssues(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ZoraV1alpha1().ClusterIssues(namespace).Watch(context.TODO(), options) + }, + }, + &zorav1alpha1.ClusterIssue{}, + resyncPeriod, + indexers, + ) +} + +func (f *clusterIssueInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredClusterIssueInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *clusterIssueInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&zorav1alpha1.ClusterIssue{}, f.defaultInformer) +} + +func (f *clusterIssueInformer) Lister() v1alpha1.ClusterIssueLister { + return v1alpha1.NewClusterIssueLister(f.Informer().GetIndexer()) +} diff --git a/pkg/informers/externalversions/zora/v1alpha1/clusterscan.go b/pkg/informers/externalversions/zora/v1alpha1/clusterscan.go new file mode 100644 index 00000000..a4a96614 --- /dev/null +++ b/pkg/informers/externalversions/zora/v1alpha1/clusterscan.go @@ -0,0 +1,74 @@ +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + zorav1alpha1 "github.com/undistro/zora/api/zora/v1alpha1" + versioned "github.com/undistro/zora/pkg/clientset/versioned" + internalinterfaces "github.com/undistro/zora/pkg/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/undistro/zora/pkg/listers/zora/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// ClusterScanInformer provides access to a shared informer and lister for +// ClusterScans. +type ClusterScanInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.ClusterScanLister +} + +type clusterScanInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewClusterScanInformer constructs a new informer for ClusterScan type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewClusterScanInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredClusterScanInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredClusterScanInformer constructs a new informer for ClusterScan type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredClusterScanInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ZoraV1alpha1().ClusterScans(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ZoraV1alpha1().ClusterScans(namespace).Watch(context.TODO(), options) + }, + }, + &zorav1alpha1.ClusterScan{}, + resyncPeriod, + indexers, + ) +} + +func (f *clusterScanInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredClusterScanInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *clusterScanInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&zorav1alpha1.ClusterScan{}, f.defaultInformer) +} + +func (f *clusterScanInformer) Lister() v1alpha1.ClusterScanLister { + return v1alpha1.NewClusterScanLister(f.Informer().GetIndexer()) +} diff --git a/pkg/informers/externalversions/zora/v1alpha1/customcheck.go b/pkg/informers/externalversions/zora/v1alpha1/customcheck.go new file mode 100644 index 00000000..22d2d773 --- /dev/null +++ b/pkg/informers/externalversions/zora/v1alpha1/customcheck.go @@ -0,0 +1,74 @@ +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + zorav1alpha1 "github.com/undistro/zora/api/zora/v1alpha1" + versioned "github.com/undistro/zora/pkg/clientset/versioned" + internalinterfaces "github.com/undistro/zora/pkg/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/undistro/zora/pkg/listers/zora/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// CustomCheckInformer provides access to a shared informer and lister for +// CustomChecks. +type CustomCheckInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.CustomCheckLister +} + +type customCheckInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewCustomCheckInformer constructs a new informer for CustomCheck type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewCustomCheckInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredCustomCheckInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredCustomCheckInformer constructs a new informer for CustomCheck type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredCustomCheckInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ZoraV1alpha1().CustomChecks(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ZoraV1alpha1().CustomChecks(namespace).Watch(context.TODO(), options) + }, + }, + &zorav1alpha1.CustomCheck{}, + resyncPeriod, + indexers, + ) +} + +func (f *customCheckInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredCustomCheckInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *customCheckInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&zorav1alpha1.CustomCheck{}, f.defaultInformer) +} + +func (f *customCheckInformer) Lister() v1alpha1.CustomCheckLister { + return v1alpha1.NewCustomCheckLister(f.Informer().GetIndexer()) +} diff --git a/pkg/informers/externalversions/zora/v1alpha1/interface.go b/pkg/informers/externalversions/zora/v1alpha1/interface.go new file mode 100644 index 00000000..18638a22 --- /dev/null +++ b/pkg/informers/externalversions/zora/v1alpha1/interface.go @@ -0,0 +1,64 @@ +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + internalinterfaces "github.com/undistro/zora/pkg/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // Clusters returns a ClusterInformer. + Clusters() ClusterInformer + // ClusterIssues returns a ClusterIssueInformer. + ClusterIssues() ClusterIssueInformer + // ClusterScans returns a ClusterScanInformer. + ClusterScans() ClusterScanInformer + // CustomChecks returns a CustomCheckInformer. + CustomChecks() CustomCheckInformer + // Plugins returns a PluginInformer. + Plugins() PluginInformer + // VulnerabilityReports returns a VulnerabilityReportInformer. + VulnerabilityReports() VulnerabilityReportInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// Clusters returns a ClusterInformer. +func (v *version) Clusters() ClusterInformer { + return &clusterInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// ClusterIssues returns a ClusterIssueInformer. +func (v *version) ClusterIssues() ClusterIssueInformer { + return &clusterIssueInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// ClusterScans returns a ClusterScanInformer. +func (v *version) ClusterScans() ClusterScanInformer { + return &clusterScanInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// CustomChecks returns a CustomCheckInformer. +func (v *version) CustomChecks() CustomCheckInformer { + return &customCheckInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Plugins returns a PluginInformer. +func (v *version) Plugins() PluginInformer { + return &pluginInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// VulnerabilityReports returns a VulnerabilityReportInformer. +func (v *version) VulnerabilityReports() VulnerabilityReportInformer { + return &vulnerabilityReportInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/informers/externalversions/zora/v1alpha1/plugin.go b/pkg/informers/externalversions/zora/v1alpha1/plugin.go new file mode 100644 index 00000000..82123220 --- /dev/null +++ b/pkg/informers/externalversions/zora/v1alpha1/plugin.go @@ -0,0 +1,74 @@ +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + zorav1alpha1 "github.com/undistro/zora/api/zora/v1alpha1" + versioned "github.com/undistro/zora/pkg/clientset/versioned" + internalinterfaces "github.com/undistro/zora/pkg/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/undistro/zora/pkg/listers/zora/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// PluginInformer provides access to a shared informer and lister for +// Plugins. +type PluginInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.PluginLister +} + +type pluginInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewPluginInformer constructs a new informer for Plugin type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewPluginInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredPluginInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredPluginInformer constructs a new informer for Plugin type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredPluginInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ZoraV1alpha1().Plugins(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ZoraV1alpha1().Plugins(namespace).Watch(context.TODO(), options) + }, + }, + &zorav1alpha1.Plugin{}, + resyncPeriod, + indexers, + ) +} + +func (f *pluginInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredPluginInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *pluginInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&zorav1alpha1.Plugin{}, f.defaultInformer) +} + +func (f *pluginInformer) Lister() v1alpha1.PluginLister { + return v1alpha1.NewPluginLister(f.Informer().GetIndexer()) +} diff --git a/pkg/informers/externalversions/zora/v1alpha1/vulnerabilityreport.go b/pkg/informers/externalversions/zora/v1alpha1/vulnerabilityreport.go new file mode 100644 index 00000000..89d08e12 --- /dev/null +++ b/pkg/informers/externalversions/zora/v1alpha1/vulnerabilityreport.go @@ -0,0 +1,74 @@ +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + zorav1alpha1 "github.com/undistro/zora/api/zora/v1alpha1" + versioned "github.com/undistro/zora/pkg/clientset/versioned" + internalinterfaces "github.com/undistro/zora/pkg/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/undistro/zora/pkg/listers/zora/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// VulnerabilityReportInformer provides access to a shared informer and lister for +// VulnerabilityReports. +type VulnerabilityReportInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.VulnerabilityReportLister +} + +type vulnerabilityReportInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewVulnerabilityReportInformer constructs a new informer for VulnerabilityReport type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewVulnerabilityReportInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredVulnerabilityReportInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredVulnerabilityReportInformer constructs a new informer for VulnerabilityReport type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredVulnerabilityReportInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ZoraV1alpha1().VulnerabilityReports(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ZoraV1alpha1().VulnerabilityReports(namespace).Watch(context.TODO(), options) + }, + }, + &zorav1alpha1.VulnerabilityReport{}, + resyncPeriod, + indexers, + ) +} + +func (f *vulnerabilityReportInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredVulnerabilityReportInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *vulnerabilityReportInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&zorav1alpha1.VulnerabilityReport{}, f.defaultInformer) +} + +func (f *vulnerabilityReportInformer) Lister() v1alpha1.VulnerabilityReportLister { + return v1alpha1.NewVulnerabilityReportLister(f.Informer().GetIndexer()) +} diff --git a/pkg/informers/externalversions/zora/v1alpha2/customcheck.go b/pkg/informers/externalversions/zora/v1alpha2/customcheck.go new file mode 100644 index 00000000..18dc769e --- /dev/null +++ b/pkg/informers/externalversions/zora/v1alpha2/customcheck.go @@ -0,0 +1,74 @@ +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + "context" + time "time" + + zorav1alpha2 "github.com/undistro/zora/api/zora/v1alpha2" + versioned "github.com/undistro/zora/pkg/clientset/versioned" + internalinterfaces "github.com/undistro/zora/pkg/informers/externalversions/internalinterfaces" + v1alpha2 "github.com/undistro/zora/pkg/listers/zora/v1alpha2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// CustomCheckInformer provides access to a shared informer and lister for +// CustomChecks. +type CustomCheckInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha2.CustomCheckLister +} + +type customCheckInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewCustomCheckInformer constructs a new informer for CustomCheck type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewCustomCheckInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredCustomCheckInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredCustomCheckInformer constructs a new informer for CustomCheck type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredCustomCheckInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ZoraV1alpha2().CustomChecks(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ZoraV1alpha2().CustomChecks(namespace).Watch(context.TODO(), options) + }, + }, + &zorav1alpha2.CustomCheck{}, + resyncPeriod, + indexers, + ) +} + +func (f *customCheckInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredCustomCheckInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *customCheckInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&zorav1alpha2.CustomCheck{}, f.defaultInformer) +} + +func (f *customCheckInformer) Lister() v1alpha2.CustomCheckLister { + return v1alpha2.NewCustomCheckLister(f.Informer().GetIndexer()) +} diff --git a/pkg/informers/externalversions/zora/v1alpha2/interface.go b/pkg/informers/externalversions/zora/v1alpha2/interface.go new file mode 100644 index 00000000..67127396 --- /dev/null +++ b/pkg/informers/externalversions/zora/v1alpha2/interface.go @@ -0,0 +1,29 @@ +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + internalinterfaces "github.com/undistro/zora/pkg/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // CustomChecks returns a CustomCheckInformer. + CustomChecks() CustomCheckInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// CustomChecks returns a CustomCheckInformer. +func (v *version) CustomChecks() CustomCheckInformer { + return &customCheckInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/listers/zora/v1alpha1/cluster.go b/pkg/listers/zora/v1alpha1/cluster.go new file mode 100644 index 00000000..bc01121e --- /dev/null +++ b/pkg/listers/zora/v1alpha1/cluster.go @@ -0,0 +1,83 @@ +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/undistro/zora/api/zora/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ClusterLister helps list Clusters. +// All objects returned here must be treated as read-only. +type ClusterLister interface { + // List lists all Clusters in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.Cluster, err error) + // Clusters returns an object that can list and get Clusters. + Clusters(namespace string) ClusterNamespaceLister + ClusterListerExpansion +} + +// clusterLister implements the ClusterLister interface. +type clusterLister struct { + indexer cache.Indexer +} + +// NewClusterLister returns a new ClusterLister. +func NewClusterLister(indexer cache.Indexer) ClusterLister { + return &clusterLister{indexer: indexer} +} + +// List lists all Clusters in the indexer. +func (s *clusterLister) List(selector labels.Selector) (ret []*v1alpha1.Cluster, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Cluster)) + }) + return ret, err +} + +// Clusters returns an object that can list and get Clusters. +func (s *clusterLister) Clusters(namespace string) ClusterNamespaceLister { + return clusterNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ClusterNamespaceLister helps list and get Clusters. +// All objects returned here must be treated as read-only. +type ClusterNamespaceLister interface { + // List lists all Clusters in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.Cluster, err error) + // Get retrieves the Cluster from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.Cluster, error) + ClusterNamespaceListerExpansion +} + +// clusterNamespaceLister implements the ClusterNamespaceLister +// interface. +type clusterNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Clusters in the indexer for a given namespace. +func (s clusterNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Cluster, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Cluster)) + }) + return ret, err +} + +// Get retrieves the Cluster from the indexer for a given namespace and name. +func (s clusterNamespaceLister) Get(name string) (*v1alpha1.Cluster, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("cluster"), name) + } + return obj.(*v1alpha1.Cluster), nil +} diff --git a/pkg/listers/zora/v1alpha1/clusterissue.go b/pkg/listers/zora/v1alpha1/clusterissue.go new file mode 100644 index 00000000..6df3b030 --- /dev/null +++ b/pkg/listers/zora/v1alpha1/clusterissue.go @@ -0,0 +1,83 @@ +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/undistro/zora/api/zora/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ClusterIssueLister helps list ClusterIssues. +// All objects returned here must be treated as read-only. +type ClusterIssueLister interface { + // List lists all ClusterIssues in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.ClusterIssue, err error) + // ClusterIssues returns an object that can list and get ClusterIssues. + ClusterIssues(namespace string) ClusterIssueNamespaceLister + ClusterIssueListerExpansion +} + +// clusterIssueLister implements the ClusterIssueLister interface. +type clusterIssueLister struct { + indexer cache.Indexer +} + +// NewClusterIssueLister returns a new ClusterIssueLister. +func NewClusterIssueLister(indexer cache.Indexer) ClusterIssueLister { + return &clusterIssueLister{indexer: indexer} +} + +// List lists all ClusterIssues in the indexer. +func (s *clusterIssueLister) List(selector labels.Selector) (ret []*v1alpha1.ClusterIssue, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.ClusterIssue)) + }) + return ret, err +} + +// ClusterIssues returns an object that can list and get ClusterIssues. +func (s *clusterIssueLister) ClusterIssues(namespace string) ClusterIssueNamespaceLister { + return clusterIssueNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ClusterIssueNamespaceLister helps list and get ClusterIssues. +// All objects returned here must be treated as read-only. +type ClusterIssueNamespaceLister interface { + // List lists all ClusterIssues in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.ClusterIssue, err error) + // Get retrieves the ClusterIssue from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.ClusterIssue, error) + ClusterIssueNamespaceListerExpansion +} + +// clusterIssueNamespaceLister implements the ClusterIssueNamespaceLister +// interface. +type clusterIssueNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all ClusterIssues in the indexer for a given namespace. +func (s clusterIssueNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.ClusterIssue, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.ClusterIssue)) + }) + return ret, err +} + +// Get retrieves the ClusterIssue from the indexer for a given namespace and name. +func (s clusterIssueNamespaceLister) Get(name string) (*v1alpha1.ClusterIssue, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("clusterissue"), name) + } + return obj.(*v1alpha1.ClusterIssue), nil +} diff --git a/pkg/listers/zora/v1alpha1/clusterscan.go b/pkg/listers/zora/v1alpha1/clusterscan.go new file mode 100644 index 00000000..b75e253a --- /dev/null +++ b/pkg/listers/zora/v1alpha1/clusterscan.go @@ -0,0 +1,83 @@ +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/undistro/zora/api/zora/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ClusterScanLister helps list ClusterScans. +// All objects returned here must be treated as read-only. +type ClusterScanLister interface { + // List lists all ClusterScans in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.ClusterScan, err error) + // ClusterScans returns an object that can list and get ClusterScans. + ClusterScans(namespace string) ClusterScanNamespaceLister + ClusterScanListerExpansion +} + +// clusterScanLister implements the ClusterScanLister interface. +type clusterScanLister struct { + indexer cache.Indexer +} + +// NewClusterScanLister returns a new ClusterScanLister. +func NewClusterScanLister(indexer cache.Indexer) ClusterScanLister { + return &clusterScanLister{indexer: indexer} +} + +// List lists all ClusterScans in the indexer. +func (s *clusterScanLister) List(selector labels.Selector) (ret []*v1alpha1.ClusterScan, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.ClusterScan)) + }) + return ret, err +} + +// ClusterScans returns an object that can list and get ClusterScans. +func (s *clusterScanLister) ClusterScans(namespace string) ClusterScanNamespaceLister { + return clusterScanNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ClusterScanNamespaceLister helps list and get ClusterScans. +// All objects returned here must be treated as read-only. +type ClusterScanNamespaceLister interface { + // List lists all ClusterScans in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.ClusterScan, err error) + // Get retrieves the ClusterScan from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.ClusterScan, error) + ClusterScanNamespaceListerExpansion +} + +// clusterScanNamespaceLister implements the ClusterScanNamespaceLister +// interface. +type clusterScanNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all ClusterScans in the indexer for a given namespace. +func (s clusterScanNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.ClusterScan, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.ClusterScan)) + }) + return ret, err +} + +// Get retrieves the ClusterScan from the indexer for a given namespace and name. +func (s clusterScanNamespaceLister) Get(name string) (*v1alpha1.ClusterScan, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("clusterscan"), name) + } + return obj.(*v1alpha1.ClusterScan), nil +} diff --git a/pkg/listers/zora/v1alpha1/customcheck.go b/pkg/listers/zora/v1alpha1/customcheck.go new file mode 100644 index 00000000..91716116 --- /dev/null +++ b/pkg/listers/zora/v1alpha1/customcheck.go @@ -0,0 +1,83 @@ +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/undistro/zora/api/zora/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// CustomCheckLister helps list CustomChecks. +// All objects returned here must be treated as read-only. +type CustomCheckLister interface { + // List lists all CustomChecks in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.CustomCheck, err error) + // CustomChecks returns an object that can list and get CustomChecks. + CustomChecks(namespace string) CustomCheckNamespaceLister + CustomCheckListerExpansion +} + +// customCheckLister implements the CustomCheckLister interface. +type customCheckLister struct { + indexer cache.Indexer +} + +// NewCustomCheckLister returns a new CustomCheckLister. +func NewCustomCheckLister(indexer cache.Indexer) CustomCheckLister { + return &customCheckLister{indexer: indexer} +} + +// List lists all CustomChecks in the indexer. +func (s *customCheckLister) List(selector labels.Selector) (ret []*v1alpha1.CustomCheck, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.CustomCheck)) + }) + return ret, err +} + +// CustomChecks returns an object that can list and get CustomChecks. +func (s *customCheckLister) CustomChecks(namespace string) CustomCheckNamespaceLister { + return customCheckNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// CustomCheckNamespaceLister helps list and get CustomChecks. +// All objects returned here must be treated as read-only. +type CustomCheckNamespaceLister interface { + // List lists all CustomChecks in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.CustomCheck, err error) + // Get retrieves the CustomCheck from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.CustomCheck, error) + CustomCheckNamespaceListerExpansion +} + +// customCheckNamespaceLister implements the CustomCheckNamespaceLister +// interface. +type customCheckNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all CustomChecks in the indexer for a given namespace. +func (s customCheckNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.CustomCheck, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.CustomCheck)) + }) + return ret, err +} + +// Get retrieves the CustomCheck from the indexer for a given namespace and name. +func (s customCheckNamespaceLister) Get(name string) (*v1alpha1.CustomCheck, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("customcheck"), name) + } + return obj.(*v1alpha1.CustomCheck), nil +} diff --git a/pkg/listers/zora/v1alpha1/expansion_generated.go b/pkg/listers/zora/v1alpha1/expansion_generated.go new file mode 100644 index 00000000..b19dfe69 --- /dev/null +++ b/pkg/listers/zora/v1alpha1/expansion_generated.go @@ -0,0 +1,51 @@ +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +// ClusterListerExpansion allows custom methods to be added to +// ClusterLister. +type ClusterListerExpansion interface{} + +// ClusterNamespaceListerExpansion allows custom methods to be added to +// ClusterNamespaceLister. +type ClusterNamespaceListerExpansion interface{} + +// ClusterIssueListerExpansion allows custom methods to be added to +// ClusterIssueLister. +type ClusterIssueListerExpansion interface{} + +// ClusterIssueNamespaceListerExpansion allows custom methods to be added to +// ClusterIssueNamespaceLister. +type ClusterIssueNamespaceListerExpansion interface{} + +// ClusterScanListerExpansion allows custom methods to be added to +// ClusterScanLister. +type ClusterScanListerExpansion interface{} + +// ClusterScanNamespaceListerExpansion allows custom methods to be added to +// ClusterScanNamespaceLister. +type ClusterScanNamespaceListerExpansion interface{} + +// CustomCheckListerExpansion allows custom methods to be added to +// CustomCheckLister. +type CustomCheckListerExpansion interface{} + +// CustomCheckNamespaceListerExpansion allows custom methods to be added to +// CustomCheckNamespaceLister. +type CustomCheckNamespaceListerExpansion interface{} + +// PluginListerExpansion allows custom methods to be added to +// PluginLister. +type PluginListerExpansion interface{} + +// PluginNamespaceListerExpansion allows custom methods to be added to +// PluginNamespaceLister. +type PluginNamespaceListerExpansion interface{} + +// VulnerabilityReportListerExpansion allows custom methods to be added to +// VulnerabilityReportLister. +type VulnerabilityReportListerExpansion interface{} + +// VulnerabilityReportNamespaceListerExpansion allows custom methods to be added to +// VulnerabilityReportNamespaceLister. +type VulnerabilityReportNamespaceListerExpansion interface{} diff --git a/pkg/listers/zora/v1alpha1/plugin.go b/pkg/listers/zora/v1alpha1/plugin.go new file mode 100644 index 00000000..c55a189b --- /dev/null +++ b/pkg/listers/zora/v1alpha1/plugin.go @@ -0,0 +1,83 @@ +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/undistro/zora/api/zora/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// PluginLister helps list Plugins. +// All objects returned here must be treated as read-only. +type PluginLister interface { + // List lists all Plugins in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.Plugin, err error) + // Plugins returns an object that can list and get Plugins. + Plugins(namespace string) PluginNamespaceLister + PluginListerExpansion +} + +// pluginLister implements the PluginLister interface. +type pluginLister struct { + indexer cache.Indexer +} + +// NewPluginLister returns a new PluginLister. +func NewPluginLister(indexer cache.Indexer) PluginLister { + return &pluginLister{indexer: indexer} +} + +// List lists all Plugins in the indexer. +func (s *pluginLister) List(selector labels.Selector) (ret []*v1alpha1.Plugin, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Plugin)) + }) + return ret, err +} + +// Plugins returns an object that can list and get Plugins. +func (s *pluginLister) Plugins(namespace string) PluginNamespaceLister { + return pluginNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// PluginNamespaceLister helps list and get Plugins. +// All objects returned here must be treated as read-only. +type PluginNamespaceLister interface { + // List lists all Plugins in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.Plugin, err error) + // Get retrieves the Plugin from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.Plugin, error) + PluginNamespaceListerExpansion +} + +// pluginNamespaceLister implements the PluginNamespaceLister +// interface. +type pluginNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Plugins in the indexer for a given namespace. +func (s pluginNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Plugin, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Plugin)) + }) + return ret, err +} + +// Get retrieves the Plugin from the indexer for a given namespace and name. +func (s pluginNamespaceLister) Get(name string) (*v1alpha1.Plugin, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("plugin"), name) + } + return obj.(*v1alpha1.Plugin), nil +} diff --git a/pkg/listers/zora/v1alpha1/vulnerabilityreport.go b/pkg/listers/zora/v1alpha1/vulnerabilityreport.go new file mode 100644 index 00000000..45520d22 --- /dev/null +++ b/pkg/listers/zora/v1alpha1/vulnerabilityreport.go @@ -0,0 +1,83 @@ +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/undistro/zora/api/zora/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// VulnerabilityReportLister helps list VulnerabilityReports. +// All objects returned here must be treated as read-only. +type VulnerabilityReportLister interface { + // List lists all VulnerabilityReports in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.VulnerabilityReport, err error) + // VulnerabilityReports returns an object that can list and get VulnerabilityReports. + VulnerabilityReports(namespace string) VulnerabilityReportNamespaceLister + VulnerabilityReportListerExpansion +} + +// vulnerabilityReportLister implements the VulnerabilityReportLister interface. +type vulnerabilityReportLister struct { + indexer cache.Indexer +} + +// NewVulnerabilityReportLister returns a new VulnerabilityReportLister. +func NewVulnerabilityReportLister(indexer cache.Indexer) VulnerabilityReportLister { + return &vulnerabilityReportLister{indexer: indexer} +} + +// List lists all VulnerabilityReports in the indexer. +func (s *vulnerabilityReportLister) List(selector labels.Selector) (ret []*v1alpha1.VulnerabilityReport, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.VulnerabilityReport)) + }) + return ret, err +} + +// VulnerabilityReports returns an object that can list and get VulnerabilityReports. +func (s *vulnerabilityReportLister) VulnerabilityReports(namespace string) VulnerabilityReportNamespaceLister { + return vulnerabilityReportNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// VulnerabilityReportNamespaceLister helps list and get VulnerabilityReports. +// All objects returned here must be treated as read-only. +type VulnerabilityReportNamespaceLister interface { + // List lists all VulnerabilityReports in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.VulnerabilityReport, err error) + // Get retrieves the VulnerabilityReport from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.VulnerabilityReport, error) + VulnerabilityReportNamespaceListerExpansion +} + +// vulnerabilityReportNamespaceLister implements the VulnerabilityReportNamespaceLister +// interface. +type vulnerabilityReportNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all VulnerabilityReports in the indexer for a given namespace. +func (s vulnerabilityReportNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.VulnerabilityReport, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.VulnerabilityReport)) + }) + return ret, err +} + +// Get retrieves the VulnerabilityReport from the indexer for a given namespace and name. +func (s vulnerabilityReportNamespaceLister) Get(name string) (*v1alpha1.VulnerabilityReport, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("vulnerabilityreport"), name) + } + return obj.(*v1alpha1.VulnerabilityReport), nil +} diff --git a/pkg/listers/zora/v1alpha2/customcheck.go b/pkg/listers/zora/v1alpha2/customcheck.go new file mode 100644 index 00000000..a0abbff6 --- /dev/null +++ b/pkg/listers/zora/v1alpha2/customcheck.go @@ -0,0 +1,83 @@ +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + v1alpha2 "github.com/undistro/zora/api/zora/v1alpha2" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// CustomCheckLister helps list CustomChecks. +// All objects returned here must be treated as read-only. +type CustomCheckLister interface { + // List lists all CustomChecks in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha2.CustomCheck, err error) + // CustomChecks returns an object that can list and get CustomChecks. + CustomChecks(namespace string) CustomCheckNamespaceLister + CustomCheckListerExpansion +} + +// customCheckLister implements the CustomCheckLister interface. +type customCheckLister struct { + indexer cache.Indexer +} + +// NewCustomCheckLister returns a new CustomCheckLister. +func NewCustomCheckLister(indexer cache.Indexer) CustomCheckLister { + return &customCheckLister{indexer: indexer} +} + +// List lists all CustomChecks in the indexer. +func (s *customCheckLister) List(selector labels.Selector) (ret []*v1alpha2.CustomCheck, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha2.CustomCheck)) + }) + return ret, err +} + +// CustomChecks returns an object that can list and get CustomChecks. +func (s *customCheckLister) CustomChecks(namespace string) CustomCheckNamespaceLister { + return customCheckNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// CustomCheckNamespaceLister helps list and get CustomChecks. +// All objects returned here must be treated as read-only. +type CustomCheckNamespaceLister interface { + // List lists all CustomChecks in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha2.CustomCheck, err error) + // Get retrieves the CustomCheck from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha2.CustomCheck, error) + CustomCheckNamespaceListerExpansion +} + +// customCheckNamespaceLister implements the CustomCheckNamespaceLister +// interface. +type customCheckNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all CustomChecks in the indexer for a given namespace. +func (s customCheckNamespaceLister) List(selector labels.Selector) (ret []*v1alpha2.CustomCheck, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha2.CustomCheck)) + }) + return ret, err +} + +// Get retrieves the CustomCheck from the indexer for a given namespace and name. +func (s customCheckNamespaceLister) Get(name string) (*v1alpha2.CustomCheck, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha2.Resource("customcheck"), name) + } + return obj.(*v1alpha2.CustomCheck), nil +} diff --git a/pkg/listers/zora/v1alpha2/expansion_generated.go b/pkg/listers/zora/v1alpha2/expansion_generated.go new file mode 100644 index 00000000..6ba69c9e --- /dev/null +++ b/pkg/listers/zora/v1alpha2/expansion_generated.go @@ -0,0 +1,11 @@ +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha2 + +// CustomCheckListerExpansion allows custom methods to be added to +// CustomCheckLister. +type CustomCheckListerExpansion interface{} + +// CustomCheckNamespaceListerExpansion allows custom methods to be added to +// CustomCheckNamespaceLister. +type CustomCheckNamespaceListerExpansion interface{}