From 89d6021e03767c0e2a0c48419ecbd8bf97ceaad9 Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Thu, 1 Aug 2024 12:10:10 +0200 Subject: [PATCH] Run codegen Signed-off-by: Stephen Kitt Kubernetes-commit: be03bcf3244e6c280b8aaf7a638d1926f0960eab --- .../typed/cr/v1/fake/fake_cr_client.go | 2 +- .../typed/cr/v1/fake/fake_example.go | 149 ++------------- go.mod | 14 +- go.sum | 28 +-- .../v1/fake/fake_apiextensions_client.go | 2 +- .../v1/fake/fake_customresourcedefinition.go | 179 +++--------------- .../v1beta1/fake/fake_apiextensions_client.go | 2 +- .../fake/fake_customresourcedefinition.go | 179 +++--------------- 8 files changed, 90 insertions(+), 465 deletions(-) diff --git a/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/fake_cr_client.go b/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/fake_cr_client.go index 5ce902313..1aff232b0 100644 --- a/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/fake_cr_client.go +++ b/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/fake_cr_client.go @@ -29,7 +29,7 @@ type FakeCrV1 struct { } func (c *FakeCrV1) Examples(namespace string) v1.ExampleInterface { - return &FakeExamples{c, namespace} + return newFakeExamples(c, namespace) } // RESTClient returns a RESTClient that is used to communicate diff --git a/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/fake_example.go b/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/fake_example.go index b0c5985b2..de534f1c0 100644 --- a/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/fake_example.go +++ b/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake/fake_example.go @@ -19,142 +19,31 @@ limitations under the License. package fake import ( - context "context" - json "encoding/json" - fmt "fmt" - v1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1" crv1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/applyconfiguration/cr/v1" - metav1 "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" + typedcrv1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1" + gentype "k8s.io/client-go/gentype" ) -// FakeExamples implements ExampleInterface -type FakeExamples struct { +// fakeExamples implements ExampleInterface +type fakeExamples struct { + *gentype.FakeClientWithListAndApply[*v1.Example, *v1.ExampleList, *crv1.ExampleApplyConfiguration] Fake *FakeCrV1 - ns string -} - -var examplesResource = v1.SchemeGroupVersion.WithResource("examples") - -var examplesKind = v1.SchemeGroupVersion.WithKind("Example") - -// Get takes name of the example, and returns the corresponding example object, and an error if there is any. -func (c *FakeExamples) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.Example, err error) { - emptyResult := &v1.Example{} - obj, err := c.Fake. - Invokes(testing.NewGetActionWithOptions(examplesResource, c.ns, name, options), emptyResult) - - if obj == nil { - return emptyResult, err - } - return obj.(*v1.Example), err -} - -// List takes label and field selectors, and returns the list of Examples that match those selectors. -func (c *FakeExamples) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ExampleList, err error) { - emptyResult := &v1.ExampleList{} - obj, err := c.Fake. - Invokes(testing.NewListActionWithOptions(examplesResource, examplesKind, c.ns, opts), emptyResult) - - if obj == nil { - return emptyResult, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1.ExampleList{ListMeta: obj.(*v1.ExampleList).ListMeta} - for _, item := range obj.(*v1.ExampleList).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 examples. -func (c *FakeExamples) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchActionWithOptions(examplesResource, c.ns, opts)) - } -// Create takes the representation of a example and creates it. Returns the server's representation of the example, and an error, if there is any. -func (c *FakeExamples) Create(ctx context.Context, example *v1.Example, opts metav1.CreateOptions) (result *v1.Example, err error) { - emptyResult := &v1.Example{} - obj, err := c.Fake. - Invokes(testing.NewCreateActionWithOptions(examplesResource, c.ns, example, opts), emptyResult) - - if obj == nil { - return emptyResult, err - } - return obj.(*v1.Example), err -} - -// Update takes the representation of a example and updates it. Returns the server's representation of the example, and an error, if there is any. -func (c *FakeExamples) Update(ctx context.Context, example *v1.Example, opts metav1.UpdateOptions) (result *v1.Example, err error) { - emptyResult := &v1.Example{} - obj, err := c.Fake. - Invokes(testing.NewUpdateActionWithOptions(examplesResource, c.ns, example, opts), emptyResult) - - if obj == nil { - return emptyResult, err - } - return obj.(*v1.Example), err -} - -// Delete takes name of the example and deletes it. Returns an error if one occurs. -func (c *FakeExamples) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteActionWithOptions(examplesResource, c.ns, name, opts), &v1.Example{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeExamples) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewDeleteCollectionActionWithOptions(examplesResource, c.ns, opts, listOpts) - - _, err := c.Fake.Invokes(action, &v1.ExampleList{}) - return err -} - -// Patch applies the patch and returns the patched example. -func (c *FakeExamples) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.Example, err error) { - emptyResult := &v1.Example{} - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceActionWithOptions(examplesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) - - if obj == nil { - return emptyResult, err - } - return obj.(*v1.Example), err -} - -// Apply takes the given apply declarative configuration, applies it and returns the applied example. -func (c *FakeExamples) Apply(ctx context.Context, example *crv1.ExampleApplyConfiguration, opts metav1.ApplyOptions) (result *v1.Example, err error) { - if example == nil { - return nil, fmt.Errorf("example provided to Apply must not be nil") - } - data, err := json.Marshal(example) - if err != nil { - return nil, err - } - name := example.Name - if name == nil { - return nil, fmt.Errorf("example.Name must be provided to Apply") - } - emptyResult := &v1.Example{} - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceActionWithOptions(examplesResource, c.ns, *name, types.ApplyPatchType, data, opts.ToPatchOptions()), emptyResult) - - if obj == nil { - return emptyResult, err +func newFakeExamples(fake *FakeCrV1, namespace string) typedcrv1.ExampleInterface { + return &fakeExamples{ + gentype.NewFakeClientWithListAndApply[*v1.Example, *v1.ExampleList, *crv1.ExampleApplyConfiguration]( + fake.Fake, + namespace, + v1.SchemeGroupVersion.WithResource("examples"), + v1.SchemeGroupVersion.WithKind("Example"), + func() *v1.Example { return &v1.Example{} }, + func() *v1.ExampleList { return &v1.ExampleList{} }, + func(dst, src *v1.ExampleList) { dst.ListMeta = src.ListMeta }, + func(list *v1.ExampleList) []*v1.Example { return gentype.ToPointerSlice(list.Items) }, + func(list *v1.ExampleList, items []*v1.Example) { list.Items = gentype.FromPointerSlice(items) }, + ), + fake, } - return obj.(*v1.Example), err } diff --git a/go.mod b/go.mod index bda40f642..64800d6a1 100644 --- a/go.mod +++ b/go.mod @@ -25,12 +25,12 @@ require ( google.golang.org/grpc v1.65.0 google.golang.org/protobuf v1.35.1 gopkg.in/evanphx/json-patch.v4 v4.12.0 - k8s.io/api v0.0.0-20241108114314-0869e9d258da + k8s.io/api v0.0.0-20241127162655-f8e5e36c84f1 k8s.io/apimachinery v0.0.0-20241108022104-96b97de8d6ba - k8s.io/apiserver v0.0.0-20241108130136-0b01a72aa368 - k8s.io/client-go v0.0.0-20241108115824-fcfb2ba0165b - k8s.io/code-generator v0.0.0-20241108122330-dd3711df8d22 - k8s.io/component-base v0.0.0-20241108123300-35b74786c418 + k8s.io/apiserver v0.0.0-20241108130139-3423727e46ef + k8s.io/client-go v0.0.0-20241127164845-55d23e26d5ef + k8s.io/code-generator v0.0.0-20241127170634-56b470edd059 + k8s.io/component-base v0.0.0-20241127171706-ad7c5246b8a7 k8s.io/klog/v2 v2.130.1 k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 @@ -122,6 +122,8 @@ require ( gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/gengo/v2 v2.0.0-20240911193312-2b36238f13e9 // indirect - k8s.io/kms v0.0.0-20241107031913-7a7a59ea9c74 // indirect + k8s.io/kms v0.0.0-20241127173318-820aadf4e421 // indirect sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.0 // indirect ) + +replace k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20240920213627-16af2ff33fbf diff --git a/go.sum b/go.sum index 85f19ba22..7a771a72b 100644 --- a/go.sum +++ b/go.sum @@ -360,24 +360,24 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -k8s.io/api v0.0.0-20241108114314-0869e9d258da h1:0IBD100isGkMfDCeLrXtOqsmKKeiy3Uj85sI50Aff7U= -k8s.io/api v0.0.0-20241108114314-0869e9d258da/go.mod h1:jw6pQTESH9mdZL2vOK3twojvpPxipl5TpLZpPyl5ZYU= -k8s.io/apimachinery v0.0.0-20241108022104-96b97de8d6ba h1:ghB5Iygt6Ge8UyIwW7C1kJx4kP7AUTCL9Qg6GCsUUOY= -k8s.io/apimachinery v0.0.0-20241108022104-96b97de8d6ba/go.mod h1:HqhdaJUgQqky29T1V0o2yFkt/pZqLFIDyn9Zi/8rxoY= -k8s.io/apiserver v0.0.0-20241108130136-0b01a72aa368 h1:lX14hbOkTWzzPIKgvqFG8OqF+sxZvps3HLL7jgjEVZ0= -k8s.io/apiserver v0.0.0-20241108130136-0b01a72aa368/go.mod h1:7ll2aKXEjrII2IQZr6FHseDBtuEWipdc/YY6P8BICBc= -k8s.io/client-go v0.0.0-20241108115824-fcfb2ba0165b h1:lS1fax+8b6ixc5eVrH2wdX0ZsJPL3aUgi5/S4WlESgI= -k8s.io/client-go v0.0.0-20241108115824-fcfb2ba0165b/go.mod h1:luyD5FCao3u3FeN1L5HS36g83otuzs6cdlUNsYdQ6dw= -k8s.io/code-generator v0.0.0-20241108122330-dd3711df8d22 h1:3jfOticRoJLwJXKtXNYBNvhsC4kKK4M0crvw5dhZ36s= -k8s.io/code-generator v0.0.0-20241108122330-dd3711df8d22/go.mod h1:g0UTC4yUhZtgKN5C6lxF/3ma2X4KY8cE+VKtIv1JAPQ= -k8s.io/component-base v0.0.0-20241108123300-35b74786c418 h1:QwfJ5xnagesBw1NsW9GQ1egcdSfNsWOyPb/2RkdZUic= -k8s.io/component-base v0.0.0-20241108123300-35b74786c418/go.mod h1:xoGVbsAaeyCMTUz4Ck1TA3Tz7SSE9Suryx+nCTkuChM= +k8s.io/api v0.0.0-20241127162655-f8e5e36c84f1 h1:MTqd8524+MzN0Kxt42qAvh/aUYC18yz1BJUmfWADaDg= +k8s.io/api v0.0.0-20241127162655-f8e5e36c84f1/go.mod h1:qs155+gTdM43TXy/cV8a8yOjDeNR8kGJc82AraJrh/c= +k8s.io/apimachinery v0.0.0-20240920213627-16af2ff33fbf h1:ZRwu8YHh3bFbQU4NRvHB6fiovWLBouxY86wIcLd7sBA= +k8s.io/apimachinery v0.0.0-20240920213627-16af2ff33fbf/go.mod h1:HqhdaJUgQqky29T1V0o2yFkt/pZqLFIDyn9Zi/8rxoY= +k8s.io/apiserver v0.0.0-20241108130139-3423727e46ef h1:UW3dV3TMUzXorcaKhgq1jhq+aLv1ji2T2410tn34hEc= +k8s.io/apiserver v0.0.0-20241108130139-3423727e46ef/go.mod h1:hCAQocw78k5SHhJB9536jyiiaHDidMVbRjRipU0ywuw= +k8s.io/client-go v0.0.0-20241127164845-55d23e26d5ef h1:vruVg7dEUvIzst/cCIMyxHj6Xh2vTpaVH9wrONW6SM4= +k8s.io/client-go v0.0.0-20241127164845-55d23e26d5ef/go.mod h1:DtqcGpVY2YUJlRhkIBvTwD/kYAIV58FrFHjjLlNR4VM= +k8s.io/code-generator v0.0.0-20241127170634-56b470edd059 h1:+pnMqlGoHe5NAep83V1PIXcLxnNoAbKvfuKO/mMJD9o= +k8s.io/code-generator v0.0.0-20241127170634-56b470edd059/go.mod h1:QKSpXtf2PO9wu/OTlRYPsRpbCstvEtj0O0hI+hf6vGM= +k8s.io/component-base v0.0.0-20241127171706-ad7c5246b8a7 h1:MIGdzfvdywTFOvy1YbN1gaqVRaLdyKJwZj2mMZFvFeI= +k8s.io/component-base v0.0.0-20241127171706-ad7c5246b8a7/go.mod h1:22TS+1cPXmvfgwlt5uwSfAMZDEIKFZWq/T/6uh2Ado4= k8s.io/gengo/v2 v2.0.0-20240911193312-2b36238f13e9 h1:si3PfKm8dDYxgfbeA6orqrtLkvvIeH8UqffFJDl0bz4= k8s.io/gengo/v2 v2.0.0-20240911193312-2b36238f13e9/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kms v0.0.0-20241107031913-7a7a59ea9c74 h1:4Ib0RezwyOw06/9W8ACHhLDxtRCgZc0IERyyivhOp/E= -k8s.io/kms v0.0.0-20241107031913-7a7a59ea9c74/go.mod h1:SYc/vvTslZFejoOBnAF/ZLaqnmJMXVJzxWZakvq0LOg= +k8s.io/kms v0.0.0-20241127173318-820aadf4e421 h1:pzX45c5lxKadJoPaJOQvG69BcJUE5rqkGKyXz2Pnfkk= +k8s.io/kms v0.0.0-20241127173318-820aadf4e421/go.mod h1:SYc/vvTslZFejoOBnAF/ZLaqnmJMXVJzxWZakvq0LOg= k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f h1:GA7//TjRY9yWGy1poLzYYJJ4JRdzg3+O6e8I+e+8T5Y= k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f/go.mod h1:R/HEjbvWI0qdfb8viZUeVZm0X6IZnxAydC7YU42CMw4= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= diff --git a/pkg/client/clientset/clientset/typed/apiextensions/v1/fake/fake_apiextensions_client.go b/pkg/client/clientset/clientset/typed/apiextensions/v1/fake/fake_apiextensions_client.go index 43b4ee7a2..e0e0048aa 100644 --- a/pkg/client/clientset/clientset/typed/apiextensions/v1/fake/fake_apiextensions_client.go +++ b/pkg/client/clientset/clientset/typed/apiextensions/v1/fake/fake_apiextensions_client.go @@ -29,7 +29,7 @@ type FakeApiextensionsV1 struct { } func (c *FakeApiextensionsV1) CustomResourceDefinitions() v1.CustomResourceDefinitionInterface { - return &FakeCustomResourceDefinitions{c} + return newFakeCustomResourceDefinitions(c) } // RESTClient returns a RESTClient that is used to communicate diff --git a/pkg/client/clientset/clientset/typed/apiextensions/v1/fake/fake_customresourcedefinition.go b/pkg/client/clientset/clientset/typed/apiextensions/v1/fake/fake_customresourcedefinition.go index 5da4cbd56..0667ea907 100644 --- a/pkg/client/clientset/clientset/typed/apiextensions/v1/fake/fake_customresourcedefinition.go +++ b/pkg/client/clientset/clientset/typed/apiextensions/v1/fake/fake_customresourcedefinition.go @@ -19,168 +19,35 @@ limitations under the License. package fake import ( - context "context" - json "encoding/json" - fmt "fmt" - v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/client/applyconfiguration/apiextensions/v1" - metav1 "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" + typedapiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1" + gentype "k8s.io/client-go/gentype" ) -// FakeCustomResourceDefinitions implements CustomResourceDefinitionInterface -type FakeCustomResourceDefinitions struct { +// fakeCustomResourceDefinitions implements CustomResourceDefinitionInterface +type fakeCustomResourceDefinitions struct { + *gentype.FakeClientWithListAndApply[*v1.CustomResourceDefinition, *v1.CustomResourceDefinitionList, *apiextensionsv1.CustomResourceDefinitionApplyConfiguration] Fake *FakeApiextensionsV1 } -var customresourcedefinitionsResource = v1.SchemeGroupVersion.WithResource("customresourcedefinitions") - -var customresourcedefinitionsKind = v1.SchemeGroupVersion.WithKind("CustomResourceDefinition") - -// Get takes name of the customResourceDefinition, and returns the corresponding customResourceDefinition object, and an error if there is any. -func (c *FakeCustomResourceDefinitions) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.CustomResourceDefinition, err error) { - emptyResult := &v1.CustomResourceDefinition{} - obj, err := c.Fake. - Invokes(testing.NewRootGetActionWithOptions(customresourcedefinitionsResource, name, options), emptyResult) - if obj == nil { - return emptyResult, err - } - return obj.(*v1.CustomResourceDefinition), err -} - -// List takes label and field selectors, and returns the list of CustomResourceDefinitions that match those selectors. -func (c *FakeCustomResourceDefinitions) List(ctx context.Context, opts metav1.ListOptions) (result *v1.CustomResourceDefinitionList, err error) { - emptyResult := &v1.CustomResourceDefinitionList{} - obj, err := c.Fake. - Invokes(testing.NewRootListActionWithOptions(customresourcedefinitionsResource, customresourcedefinitionsKind, opts), emptyResult) - if obj == nil { - return emptyResult, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1.CustomResourceDefinitionList{ListMeta: obj.(*v1.CustomResourceDefinitionList).ListMeta} - for _, item := range obj.(*v1.CustomResourceDefinitionList).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 customResourceDefinitions. -func (c *FakeCustomResourceDefinitions) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewRootWatchActionWithOptions(customresourcedefinitionsResource, opts)) -} - -// Create takes the representation of a customResourceDefinition and creates it. Returns the server's representation of the customResourceDefinition, and an error, if there is any. -func (c *FakeCustomResourceDefinitions) Create(ctx context.Context, customResourceDefinition *v1.CustomResourceDefinition, opts metav1.CreateOptions) (result *v1.CustomResourceDefinition, err error) { - emptyResult := &v1.CustomResourceDefinition{} - obj, err := c.Fake. - Invokes(testing.NewRootCreateActionWithOptions(customresourcedefinitionsResource, customResourceDefinition, opts), emptyResult) - if obj == nil { - return emptyResult, err - } - return obj.(*v1.CustomResourceDefinition), err -} - -// Update takes the representation of a customResourceDefinition and updates it. Returns the server's representation of the customResourceDefinition, and an error, if there is any. -func (c *FakeCustomResourceDefinitions) Update(ctx context.Context, customResourceDefinition *v1.CustomResourceDefinition, opts metav1.UpdateOptions) (result *v1.CustomResourceDefinition, err error) { - emptyResult := &v1.CustomResourceDefinition{} - obj, err := c.Fake. - Invokes(testing.NewRootUpdateActionWithOptions(customresourcedefinitionsResource, customResourceDefinition, opts), emptyResult) - if obj == nil { - return emptyResult, err - } - return obj.(*v1.CustomResourceDefinition), 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 *FakeCustomResourceDefinitions) UpdateStatus(ctx context.Context, customResourceDefinition *v1.CustomResourceDefinition, opts metav1.UpdateOptions) (result *v1.CustomResourceDefinition, err error) { - emptyResult := &v1.CustomResourceDefinition{} - obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceActionWithOptions(customresourcedefinitionsResource, "status", customResourceDefinition, opts), emptyResult) - if obj == nil { - return emptyResult, err - } - return obj.(*v1.CustomResourceDefinition), err -} - -// Delete takes name of the customResourceDefinition and deletes it. Returns an error if one occurs. -func (c *FakeCustomResourceDefinitions) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewRootDeleteActionWithOptions(customresourcedefinitionsResource, name, opts), &v1.CustomResourceDefinition{}) - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeCustomResourceDefinitions) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewRootDeleteCollectionActionWithOptions(customresourcedefinitionsResource, opts, listOpts) - - _, err := c.Fake.Invokes(action, &v1.CustomResourceDefinitionList{}) - return err -} - -// Patch applies the patch and returns the patched customResourceDefinition. -func (c *FakeCustomResourceDefinitions) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.CustomResourceDefinition, err error) { - emptyResult := &v1.CustomResourceDefinition{} - obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(customresourcedefinitionsResource, name, pt, data, opts, subresources...), emptyResult) - if obj == nil { - return emptyResult, err - } - return obj.(*v1.CustomResourceDefinition), err -} - -// Apply takes the given apply declarative configuration, applies it and returns the applied customResourceDefinition. -func (c *FakeCustomResourceDefinitions) Apply(ctx context.Context, customResourceDefinition *apiextensionsv1.CustomResourceDefinitionApplyConfiguration, opts metav1.ApplyOptions) (result *v1.CustomResourceDefinition, err error) { - if customResourceDefinition == nil { - return nil, fmt.Errorf("customResourceDefinition provided to Apply must not be nil") - } - data, err := json.Marshal(customResourceDefinition) - if err != nil { - return nil, err - } - name := customResourceDefinition.Name - if name == nil { - return nil, fmt.Errorf("customResourceDefinition.Name must be provided to Apply") - } - emptyResult := &v1.CustomResourceDefinition{} - obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(customresourcedefinitionsResource, *name, types.ApplyPatchType, data, opts.ToPatchOptions()), emptyResult) - if obj == nil { - return emptyResult, err - } - return obj.(*v1.CustomResourceDefinition), err -} - -// ApplyStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). -func (c *FakeCustomResourceDefinitions) ApplyStatus(ctx context.Context, customResourceDefinition *apiextensionsv1.CustomResourceDefinitionApplyConfiguration, opts metav1.ApplyOptions) (result *v1.CustomResourceDefinition, err error) { - if customResourceDefinition == nil { - return nil, fmt.Errorf("customResourceDefinition provided to Apply must not be nil") - } - data, err := json.Marshal(customResourceDefinition) - if err != nil { - return nil, err - } - name := customResourceDefinition.Name - if name == nil { - return nil, fmt.Errorf("customResourceDefinition.Name must be provided to Apply") - } - emptyResult := &v1.CustomResourceDefinition{} - obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(customresourcedefinitionsResource, *name, types.ApplyPatchType, data, opts.ToPatchOptions(), "status"), emptyResult) - if obj == nil { - return emptyResult, err +func newFakeCustomResourceDefinitions(fake *FakeApiextensionsV1) typedapiextensionsv1.CustomResourceDefinitionInterface { + return &fakeCustomResourceDefinitions{ + gentype.NewFakeClientWithListAndApply[*v1.CustomResourceDefinition, *v1.CustomResourceDefinitionList, *apiextensionsv1.CustomResourceDefinitionApplyConfiguration]( + fake.Fake, + "", + v1.SchemeGroupVersion.WithResource("customresourcedefinitions"), + v1.SchemeGroupVersion.WithKind("CustomResourceDefinition"), + func() *v1.CustomResourceDefinition { return &v1.CustomResourceDefinition{} }, + func() *v1.CustomResourceDefinitionList { return &v1.CustomResourceDefinitionList{} }, + func(dst, src *v1.CustomResourceDefinitionList) { dst.ListMeta = src.ListMeta }, + func(list *v1.CustomResourceDefinitionList) []*v1.CustomResourceDefinition { + return gentype.ToPointerSlice(list.Items) + }, + func(list *v1.CustomResourceDefinitionList, items []*v1.CustomResourceDefinition) { + list.Items = gentype.FromPointerSlice(items) + }, + ), + fake, } - return obj.(*v1.CustomResourceDefinition), err } diff --git a/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/fake_apiextensions_client.go b/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/fake_apiextensions_client.go index 288683ef9..2cc0b5342 100644 --- a/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/fake_apiextensions_client.go +++ b/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/fake_apiextensions_client.go @@ -29,7 +29,7 @@ type FakeApiextensionsV1beta1 struct { } func (c *FakeApiextensionsV1beta1) CustomResourceDefinitions() v1beta1.CustomResourceDefinitionInterface { - return &FakeCustomResourceDefinitions{c} + return newFakeCustomResourceDefinitions(c) } // RESTClient returns a RESTClient that is used to communicate diff --git a/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/fake_customresourcedefinition.go b/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/fake_customresourcedefinition.go index 4552bc164..9fbe167b6 100644 --- a/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/fake_customresourcedefinition.go +++ b/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/fake/fake_customresourcedefinition.go @@ -19,168 +19,35 @@ limitations under the License. package fake import ( - context "context" - json "encoding/json" - fmt "fmt" - v1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/client/applyconfiguration/apiextensions/v1beta1" - 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" + typedapiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1" + gentype "k8s.io/client-go/gentype" ) -// FakeCustomResourceDefinitions implements CustomResourceDefinitionInterface -type FakeCustomResourceDefinitions struct { +// fakeCustomResourceDefinitions implements CustomResourceDefinitionInterface +type fakeCustomResourceDefinitions struct { + *gentype.FakeClientWithListAndApply[*v1beta1.CustomResourceDefinition, *v1beta1.CustomResourceDefinitionList, *apiextensionsv1beta1.CustomResourceDefinitionApplyConfiguration] Fake *FakeApiextensionsV1beta1 } -var customresourcedefinitionsResource = v1beta1.SchemeGroupVersion.WithResource("customresourcedefinitions") - -var customresourcedefinitionsKind = v1beta1.SchemeGroupVersion.WithKind("CustomResourceDefinition") - -// Get takes name of the customResourceDefinition, and returns the corresponding customResourceDefinition object, and an error if there is any. -func (c *FakeCustomResourceDefinitions) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.CustomResourceDefinition, err error) { - emptyResult := &v1beta1.CustomResourceDefinition{} - obj, err := c.Fake. - Invokes(testing.NewRootGetActionWithOptions(customresourcedefinitionsResource, name, options), emptyResult) - if obj == nil { - return emptyResult, err - } - return obj.(*v1beta1.CustomResourceDefinition), err -} - -// List takes label and field selectors, and returns the list of CustomResourceDefinitions that match those selectors. -func (c *FakeCustomResourceDefinitions) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.CustomResourceDefinitionList, err error) { - emptyResult := &v1beta1.CustomResourceDefinitionList{} - obj, err := c.Fake. - Invokes(testing.NewRootListActionWithOptions(customresourcedefinitionsResource, customresourcedefinitionsKind, opts), emptyResult) - if obj == nil { - return emptyResult, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1beta1.CustomResourceDefinitionList{ListMeta: obj.(*v1beta1.CustomResourceDefinitionList).ListMeta} - for _, item := range obj.(*v1beta1.CustomResourceDefinitionList).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 customResourceDefinitions. -func (c *FakeCustomResourceDefinitions) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewRootWatchActionWithOptions(customresourcedefinitionsResource, opts)) -} - -// Create takes the representation of a customResourceDefinition and creates it. Returns the server's representation of the customResourceDefinition, and an error, if there is any. -func (c *FakeCustomResourceDefinitions) Create(ctx context.Context, customResourceDefinition *v1beta1.CustomResourceDefinition, opts v1.CreateOptions) (result *v1beta1.CustomResourceDefinition, err error) { - emptyResult := &v1beta1.CustomResourceDefinition{} - obj, err := c.Fake. - Invokes(testing.NewRootCreateActionWithOptions(customresourcedefinitionsResource, customResourceDefinition, opts), emptyResult) - if obj == nil { - return emptyResult, err - } - return obj.(*v1beta1.CustomResourceDefinition), err -} - -// Update takes the representation of a customResourceDefinition and updates it. Returns the server's representation of the customResourceDefinition, and an error, if there is any. -func (c *FakeCustomResourceDefinitions) Update(ctx context.Context, customResourceDefinition *v1beta1.CustomResourceDefinition, opts v1.UpdateOptions) (result *v1beta1.CustomResourceDefinition, err error) { - emptyResult := &v1beta1.CustomResourceDefinition{} - obj, err := c.Fake. - Invokes(testing.NewRootUpdateActionWithOptions(customresourcedefinitionsResource, customResourceDefinition, opts), emptyResult) - if obj == nil { - return emptyResult, err - } - return obj.(*v1beta1.CustomResourceDefinition), 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 *FakeCustomResourceDefinitions) UpdateStatus(ctx context.Context, customResourceDefinition *v1beta1.CustomResourceDefinition, opts v1.UpdateOptions) (result *v1beta1.CustomResourceDefinition, err error) { - emptyResult := &v1beta1.CustomResourceDefinition{} - obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceActionWithOptions(customresourcedefinitionsResource, "status", customResourceDefinition, opts), emptyResult) - if obj == nil { - return emptyResult, err - } - return obj.(*v1beta1.CustomResourceDefinition), err -} - -// Delete takes name of the customResourceDefinition and deletes it. Returns an error if one occurs. -func (c *FakeCustomResourceDefinitions) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewRootDeleteActionWithOptions(customresourcedefinitionsResource, name, opts), &v1beta1.CustomResourceDefinition{}) - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeCustomResourceDefinitions) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewRootDeleteCollectionActionWithOptions(customresourcedefinitionsResource, opts, listOpts) - - _, err := c.Fake.Invokes(action, &v1beta1.CustomResourceDefinitionList{}) - return err -} - -// Patch applies the patch and returns the patched customResourceDefinition. -func (c *FakeCustomResourceDefinitions) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.CustomResourceDefinition, err error) { - emptyResult := &v1beta1.CustomResourceDefinition{} - obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(customresourcedefinitionsResource, name, pt, data, opts, subresources...), emptyResult) - if obj == nil { - return emptyResult, err - } - return obj.(*v1beta1.CustomResourceDefinition), err -} - -// Apply takes the given apply declarative configuration, applies it and returns the applied customResourceDefinition. -func (c *FakeCustomResourceDefinitions) Apply(ctx context.Context, customResourceDefinition *apiextensionsv1beta1.CustomResourceDefinitionApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.CustomResourceDefinition, err error) { - if customResourceDefinition == nil { - return nil, fmt.Errorf("customResourceDefinition provided to Apply must not be nil") - } - data, err := json.Marshal(customResourceDefinition) - if err != nil { - return nil, err - } - name := customResourceDefinition.Name - if name == nil { - return nil, fmt.Errorf("customResourceDefinition.Name must be provided to Apply") - } - emptyResult := &v1beta1.CustomResourceDefinition{} - obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(customresourcedefinitionsResource, *name, types.ApplyPatchType, data, opts.ToPatchOptions()), emptyResult) - if obj == nil { - return emptyResult, err - } - return obj.(*v1beta1.CustomResourceDefinition), err -} - -// ApplyStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). -func (c *FakeCustomResourceDefinitions) ApplyStatus(ctx context.Context, customResourceDefinition *apiextensionsv1beta1.CustomResourceDefinitionApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.CustomResourceDefinition, err error) { - if customResourceDefinition == nil { - return nil, fmt.Errorf("customResourceDefinition provided to Apply must not be nil") - } - data, err := json.Marshal(customResourceDefinition) - if err != nil { - return nil, err - } - name := customResourceDefinition.Name - if name == nil { - return nil, fmt.Errorf("customResourceDefinition.Name must be provided to Apply") - } - emptyResult := &v1beta1.CustomResourceDefinition{} - obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(customresourcedefinitionsResource, *name, types.ApplyPatchType, data, opts.ToPatchOptions(), "status"), emptyResult) - if obj == nil { - return emptyResult, err +func newFakeCustomResourceDefinitions(fake *FakeApiextensionsV1beta1) typedapiextensionsv1beta1.CustomResourceDefinitionInterface { + return &fakeCustomResourceDefinitions{ + gentype.NewFakeClientWithListAndApply[*v1beta1.CustomResourceDefinition, *v1beta1.CustomResourceDefinitionList, *apiextensionsv1beta1.CustomResourceDefinitionApplyConfiguration]( + fake.Fake, + "", + v1beta1.SchemeGroupVersion.WithResource("customresourcedefinitions"), + v1beta1.SchemeGroupVersion.WithKind("CustomResourceDefinition"), + func() *v1beta1.CustomResourceDefinition { return &v1beta1.CustomResourceDefinition{} }, + func() *v1beta1.CustomResourceDefinitionList { return &v1beta1.CustomResourceDefinitionList{} }, + func(dst, src *v1beta1.CustomResourceDefinitionList) { dst.ListMeta = src.ListMeta }, + func(list *v1beta1.CustomResourceDefinitionList) []*v1beta1.CustomResourceDefinition { + return gentype.ToPointerSlice(list.Items) + }, + func(list *v1beta1.CustomResourceDefinitionList, items []*v1beta1.CustomResourceDefinition) { + list.Items = gentype.FromPointerSlice(items) + }, + ), + fake, } - return obj.(*v1beta1.CustomResourceDefinition), err }